Sql-server – SQL Server Management Studio: how to parse stored procedure code and check if table columns exist

parsesql-server-2008ssms

I'm afraid that SSMS won't parse table columns within a stored procedure.

When you click in Parse option

enter image description here

SSMS says that parse is completed, even when a procedure is selecting a column that does not exists in a table.

When you run your script, SSMS shows what the Parse should warn about:

enter image description here

Is there a way to parse a script in order to check if table fields really exist before creating or altering procedures?

Best Answer

I don't think there's any way to do this with a parse, but you could try running the script inside a transaction then rolling back that transaction at the end. If there's an error, it should throw it, but even if there isn't, there won't be any lasting changes.