原因分析:if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[a_vw_AllBarcode]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[a_vw_AllBarcode]
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
CREATE View dbo.a_vw_AllBarcode
as
Select s_ID,barcode From Product where barcode is not null
Union
select Prod_Id,barcode From Productbarcode
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
declare tb cursor for
--刷新视图处理的语句
select 'exec sp_refreshview ''['+replace(user_name(uid), N']',N']]')+'].['
+replace(object_name(id),N']',N']]')+']'''
from dbo.sysobjects
where xtype='v' and status>=0
union all--刷新存储过程,自定义函数,触发器的语句
select 'exec sp_recompile ''[' + replace(user_name(uid), N']', N']]')+'].['
+ replace(object_name(id), N']', N']]')+ ']'''
from dbo.sysobjects
where xtype in('tr','fn','if','tf','p') and status>=0
declare @s nvarchar(4000)
open tb
fetch tb into @s
while @@fetch_status=0
begin
exec(@s)
fetch tb into @s
end
close tb
deallocate tb