Thursday, 26 September 2013

Deferred Name Resolution, or “Why does my proc allow invalid table names?”


A developer came to me a few days ago, wondering why when he specifies an invalid table name in a stored procedure, the proc saves to the database, but when he specifies an invalid column name it fails.
Looks like the deferred name resolution only works w/ missing tables…not w/ missing columns: 

http://msdn.microsoft.com/en-us/library/ms190686.aspx

For instance, this succeeds on an DB:

create proc cp_test
as
select somecolumn from tFakeTable –fake column, fake table
This fails on an DB:
create proc cp_test2
as
select somecolumn from tActualTable–fake column, real table


No comments: