declare @viewname varchar(250),@id int,@text varchar(8000)
declare #aa cursor for select id,name
from sysobjects
where objectproperty(id, 'IsView ')=1 and uid=1 and left(name,3) <> 'sys '
open #aa
fetch next from #aa into @id,@viewname
while @@fetch_status=0
begin
select @text= ' '
select @text=@text+char(13)+text
from syscomments
where id=@id
exec( 'drop view '+@viewname)
-- print @viewname
exec(@text)
-- print @text
fetch next from #aa into @id,@viewname
end
close #aa
deallocate #aa
declare #aa cursor for select id,name
from sysobjects
where objectproperty(id, 'IsView ')=1 and uid=1 and left(name,3) <> 'sys '
open #aa
fetch next from #aa into @id,@viewname
while @@fetch_status=0
begin
select @text= ' '
select @text=@text+char(13)+text
from syscomments
where id=@id
exec( 'drop view '+@viewname)
-- print @viewname
exec(@text)
-- print @text
fetch next from #aa into @id,@viewname
end
close #aa
deallocate #aa
运行一下以上sql即可以更新所有视图