Search a string in sql server database at design time [closed]
I was wondering if there is any way to search a string in whole database while designing (something like searching a string in visual studio entire solution) Edit: I mean searchi开发者_C百科ng a string in all stored procedures , functions , tables ... its useful for doing some operations like updating all stored procedures and functions after changing a column type for some table.
I use microsoft sql server 2008
thanks
I think, you need RedGate SQLSearch tool. This tool is free.
To look for code in the database you can search sys.sql_modules (see example) or use something like Red Gate SQL Search which is free
I assume this is what you mean when you want the design time VS search. Note that database code live in system tables: not in files. Hence this SQL or tool is required.
SQL example:
SELECT
OBJECT_SCHEMA_NAME(object_id) + '.' + OBJECT_NAME(object_id)
FROM
sys.sql_modules
WHERE
definition like '%whatever%'
Note: syscomments is legacy and splits the definition into nvarchar 4000 chunks thus risking not finding what you want. The same applies to INFORMATION_SCHEMA.ROUTINES
Though use case is really not useful, there is no way to search data like that, you must write sql to do so.
If you want to search objects ,there are some free add ins available which can help you search the tables, views, stored procedures and functions using a keyword.
Take a look at: http://weblogs.sqlteam.com/mladenp/archive/2007/11/20/Free-SQL-Server-tools-that-might-make-your-life-a.aspx
If I understood correctly - you need full-text search in database. It's database dependent, what database engine do you use? For MSSQL have a look at Full-Text Search (SQL Server)
One option is to use the Generate and Publish Scripts Wizard and create a script for all database objects. Then use a free text editor like Notepad++ to search through the script for the string.
精彩评论