Reference Information. A procedure is stored there that "populates" the temporary table with the given name. The procedure is general in that it checks the schema of the temp table and then does different βthingsβ depending on the schema. I understand that this is a little strange, but I do not want to change it, because everything works fine in most situations except ....
If I have a stored procedure that creates two different schemas for a temp table with the same name. Logically, it creates only one temporary table, depending on the IF branch. The problem is that when Sproc is checked by SQL Server, it seems like it evaluates both sides of IF (which makes sense if it checks the SQL syntax.)
So this SQL crashes:
IF (1=1) BEGIN CREATE TABLE
with the following error:
Msg 2714, Level 16, State 1, Line 14
An object already exists with the name '#test' in the database.
No combination of drag and drop tables inside ifs (before or after creating the DDL table) seems to satisfy the sql checker.
Any ideas how I can do this? Can I, for example, tell SQL not to do syntax checking and just accept sproc as it is?
sql-server tsql sql-server-2008-r2
Daniel James Bryars
source share