开发者

How do I use IF statement within Execute SQL task to create a temp table?

开发者 https://www.devze.com 2023-03-25 02:46 出处:网络
In my Execute SQL task I\'m creating temp table with : CREATE TABLE [tempdb].dbo.##temptable (开发者_开发技巧Header VARCHAR(200), Value VARCHAR(200))

In my Execute SQL task I'm creating temp table with :

CREATE TABLE [tempdb].dbo.##temptable (开发者_开发技巧Header VARCHAR(200), Value VARCHAR(200))

but i need to put if condition like if(temp table is exist drop it and again create new one.)

How can i do this??


The SQL statement in the Execute SQL Task would be as following:

IF OBJECT_ID('tempdb..##temptable') IS NOT NULL
    DROP TABLE [tempdb].dbo.##temptable

CREATE TABLE [tempdb].dbo.##temptable (Header VARCHAR(200), [Value] VARCHAR(200))

Screenshots:

#1:

How do I use IF statement within Execute SQL task to create a temp table?

#2:

How do I use IF statement within Execute SQL task to create a temp table?

0

精彩评论

暂无评论...
验证码 换一张
取 消