府谷县政府网,古装美女换装小游戏,书包网 h
在数据库view的创建中,会遇到一些跨数据库的view脚本,但是在将view更新到production的时候可能忘记更改database name,导致出现一些问题。
以下脚本可以检查出包含某个关键字的view name,只需要修改where objecttext like '%word%'
条件即可
--type(v,fn,p) select name,row_number()over(order by name) as number into #tempobjects from sys.objects where type='v' -- declare @rowindex int declare @rowcount int -- select @rowcount=count(*) from #tempobjects set @rowindex=1 -- create table #tempfindobjecttext(objecttext varchar(max)) create table #tempfindobject(objectname varchar(500)) -- declare @objectname varchar(500) -- while @rowindex<=@rowcount begin select @objectname=name from #tempobjects where number=@rowindex -- truncate table #tempfindobjecttext -- insert into #tempfindobjecttext(objecttext) execute sp_helptext @objectname -- if exists(select top 1 * from #tempfindobjecttext where objecttext like '%word%') begin insert into #tempfindobject(objectname)values(@objectname) end -- set @rowindex=@rowindex+1 end -- select * from #tempfindobject -- truncate table #tempobjects truncate table #tempfindobjecttext truncate table #tempfindobject -- drop table #tempobjects drop table #tempfindobjecttext drop table #tempfindobject
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
数据库SQL---数据库、基本表、视图、索引的定义、修改、删除
在 Azure CentOS VM 中配置 SQL Server 2019 AG - (上)
在 Azure CentOS VM 中配置 SQL Server 2019 AG - (下)
网友评论