Re: Create Table within If not Exists does not work
Unfortunately, T-SQL seems to parse the procs without checking for "conditionals". You will find the same flaw then trying to create indexes. Perhaps you can use a "shell script" to get around this ...
Originally posted by janmos
Create Proc test_proc
if not exists( SELECT *
FROM sysobjects a, syscolumns b
WHERE a.ID = object_id( 'my_table' ) )
create table my_table (a int, b int)
Why does this give me an error when "my_table" exists.???
error: "There is already an object called 'my_table' in the database"