how to search Sql Server 2008 R2 stored procedures for a string?

五迷三道 提交于 2019-12-17 18:52:53

问题


I'm migrating a legacy SQLS2k to 2008R2, and it seems all data access was done through stored procs, and any custom queries use the legacy *= =* outer join syntax. There are upwards of a hundred procs so I don't want to open each one individually to see if it uses that syntax (most wouldn't), is there a way I can query the metadata for a list of procs/functions/views/triggers, then loop through searching for the *= or =* strings, printing out the name of the offending object?

My background is oracle, I know how to find the metadata views there, but I'm a bit new to Sql Server. Downgrading the compatibility version is not an option.

thanks!


回答1:


Free Red Gate SQL Search?

Or query sys.sql_modules

SELECT OBJECT_NAME(object_id)
FROM sys.sql_modules
WHERE definition LIKE '%=*%' OR definition LIKE '%*=%'

Note: INFORMATION_SCHEMA views and syscomments truncate the definition so are unreliable.




回答2:


Problem with using queries is that these don’t work if stored procedure is encrypted unless you’re running DAC connection type.

This is where third party tool come in handy because they help you do this without too much hassle. I’m using ApexSQL Search that’s free but I guess you can’t go wrong with Red Gate or any other tool out there.



来源:https://stackoverflow.com/questions/6354256/how-to-search-sql-server-2008-r2-stored-procedures-for-a-string

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!