在数据库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

最新文章

  1. Oracle碎碎念~2
  2. Java中值传递和引用传递的概念
  3. textarea光标处插入文字
  4. 20145211 《Java程序设计》第1周学习总结——小荷才露尖尖角
  5. Razor语法学习
  6. POJ 2763 Housewife Wind (树链剖分 有修改单边权)
  7. JDK+Tomcat+MyEclipse发布JSP项目——不能成功的问题
  8. django: db howto - 1
  9. 人脸对齐ASM-AAM-CLM的一些总结
  10. 自己主动机串标:Directed Acyclic Word Graph
  11. Linux文件
  12. percona-toolkit 之 【pt-online-schema-change】说明【转】
  13. centos设置网卡开机自启动
  14. 浅谈.net中数据库操作事务
  15. php框架中,try,catch不能用的问题(转载)
  16. css盒子模型之边框
  17. 【JS点滴】substring和substr以及slice和splice的用法和区别。
  18. Net Core 使用外部登陆提供程序登陆的流程,以及身份认证的流程
  19. Class.forName和ClassLoader.loadClass的比较【转载】
  20. wampserver下配置虚拟主机 实现多站点支持

热门文章

  1. python去掉字符串中重复字符的方法
  2. mysql5.7版本以上下载安装
  3. Spring Cloud Gateway(五):路由定位器 RouteLocator
  4. 查看日志tail命令
  5. 简单理解Spring之IOC和AOP及代码示例
  6. 使用多个tomcat如何修改端口号
  7. Python JSON 字符串 转 json 基本使用
  8. Linux中 mv(文件移动)
  9. OpenJudge计算概论-数字求和
  10. JMeter学习-参数化