Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have an issue in SQL Server 2016

I created a store procedure in my dev environment. It is good to go and when I move my procedure to a UAT environment, it is created without a reference table (while those I used in my SP on dev were not created on UAT, but procedure created successfully). SSMS doesn't throw an error of "object not exist" mean script created without compilation.

Can anyone explain is this a bug in SSMS, or an issue with my SSMS settings, or does Microsoft allow us to do this?

A lot of times I have seen that when a particular column does not exist then it throws the error, but right now this is happening to me.

I really appreciate your reply regarding this.

Thanks in advance,
Wajid Hussain

What I have tried:

SQL
CREATE PROC test
as
BEGIN 
SELECT s_name,t_name FROM table_not_exist
END
Posted
Updated 8-Feb-22 9:56am
v2

1 solution

This is not a bug; it's a feature called "deferred name resolution".
You may be wondering why SQL Server lets you do something so stupid, but there is a good reason. Many stored procs have steps with tables, possibly temp tables or table variables, that are created inside the proc. You can also have dynamically created T-SQL in a proc. If the table names were resolved at create time, then it would not be possible to do these things.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900