czwartek, 19 listopada 2015

Search sql server database for string by sys.sql_modules

sys.sql_modules

Returns a row for each object that is an SQL language-defined module. Objects of type P, RF, V, TR, FN, IF, TF, and R have an associated SQL module. Stand-alone defaults, objects of type D, also have an SQL module definition in this view.



SELECT OBJECT_NAME(parent_object_id) as parent_object_name, SCHEMA_NAME(schema_id) as schema_name, type, name, definition
FROM sys.sql_modules m
inner join sys.objects o on o.object_id = m.object_id
where definition like '%searchin_text%'
order by type


Object TYPE:


Type ID
Type description
AF
 Aggregate function (CLR)
C
 CHECK constraint
D
 DEFAULT (constraint or stand-alone)
F
 FOREIGN KEY constraint
FN
 SQL scalar function
FS
 Assembly (CLR) scalar-function
FT
 Assembly (CLR) table-valued function
IF
 SQL inline table-valued function
IT
 Internal table
P
 SQL Stored Procedure
PC
 Assembly (CLR) stored-procedure
PG
 Plan guide
PK
 PRIMARY KEY constraint
R
 Rule (old-style, stand-alone)
RF
 Replication-filter-procedure
S
 System base table
SN
 Synonym
SO
 Sequence object
SQ
 Service queue
TA
 Assembly (CLR) DML trigger
TF
 SQL table-valued-function
TR
 SQL DML trigger
TT
 Table type
U
 Table (user-defined)
UQ
 UNIQUE constraint
V
 View
X
 Extended stored procedure


https://msdn.microsoft.com/pl-pl/library/ms175081%28v=sql.110%29.aspx
https://msdn.microsoft.com/pl-pl/library/ms190324%28v=sql.110%29.aspx
http://solutioncenter.apexsql.com/quickly-search-for-sql-database-data-and-objects/
https://sqlwithmanoj.wordpress.com/2012/08/01/search-a-string-in-stored-procedure-view-function-or-other-database-object-definitions/

Brak komentarzy:

Prześlij komentarz