Search code examples
sqlsql-servert-sqlstored-procedureslocaldb

Cause creation of stored procedure to fail if referencing non-existant tables / columns


Given the following stored procedure definition

create procedure myproc
as

select * 
from sometablethatdoesnotexist

select somecolumnthatdoesnotexist 
from sometablethatdoesexist

Is it possible to configure sql-server (or localdb) to fail the creation of the stored procedure if at the time the stored procedure is created these objects do not exist? (either column or table)


Solution

  • No.

    This is SQL Server's deferred name resolution.

    There is no way of turning it off. It will fail if you reference a non existent column on an existing table though.