In relation with this question : I'm trying to use the following query
IF NOT EXISTS(
SELECT T.name FROM SYS.TABLES T JOIN SYS.SCHEMAS S ON (T.SCHEMA_ID = S.SCHEMA_ID)
WHERE S.NAME = 'DBO' AND T.NAME = 'sample2Prot'
)
BEGIN CREATE TABLE[TCPDUMP].[dbo].[sample2Prot]
(
[IdTransmission] INT IDENTITY(1, 1) NOT NULL,
[timestp] NVARCHAR(32) NULL,
[idq] NVARCHAR(32) NULL,
[idz] NVARCHAR(32) NULL,
[prot] NVARCHAR(32) NULL,
[Lhowmany] NVARCHAR(32) NULL,
[Rhowmany] NVARCHAR(32) NULL,
CONSTRAINT[PK_TCPDump] PRIMARY KEY CLUSTERED([IdTransmission] ASC)
)
END;
The CREATE my_table.."
part works, but if the table already exists, the program raises an error during the execution : it seems that the "if not exists" statement does not work. Anyone has an explanation ?
Feel free to ask for more details