2、新建表
if not exists (select * from sys.tables where name = 'table2')
begin
create table (...)
end
3、修改列
if not exists (select * from sys.columns, sys.tables
where sys.columns.object_id = sys.tables.object_id
and sys.columns.name ='fIEld3'
and sys.tables.name ='table3')
begin
alter table add fIEld3 varchar(50)
end
else
begin
alter table alter column fIEld3 varchar(50)
-- alter table del column fIEld3
end
4、修改視圖、存儲過程、同義詞等
--視圖
if exists (select * from sys.views where name = 'vIEw1')
drop view vIEw1
go
create view vIEw1
...
--存儲過程
if exists (select * from sys.objects where name = 'proceduer1')
drop proc procedure1
go
create proc procedure1
...
--同義詞
if exists (select * from sys.synonyms where name = 'synonyms1')
drop synonyms synonyms1
go
create synonyms synonyms1
...