· 8 years ago · Aug 23, 2018, 02:44 PM
1--if table exists - drop
2If OBJECT_ID('A','U') is not null
3Drop Table [A]
4--if table not exists - Create
5Create Table A([key] varchar(20), [value] varchar(max))
6
7If OBJECT_ID('VA','V') is not null
8Drop view [VA]
9
10If OBJECT_ID('VA','V') is null
11Create view [VA] as Select * from [A]
12
13If OBJECT_ID('Trigger_A_ins','TR') is null
14Create trigger [Trigger_A_ins] On [A] instead of insert As
15 insert into A select * from inserted