[SQL] SQL Server in the view (View), pre-existing process (Stored Procedure), scalar functions, data sheets and other functions, with sys.sysobjects and sys.syscomments search keywords.
Search for keyword in SQL Server
When you want to search for a specific keyword in SQL Server's View (View), pre-existing process (Stored Procedure), scalar functions, data sheets and other functions .. exists.
Use sys.sysobjcets and sys.syscomments search, SQL syntax is as follows:
SELECT *
FROM sys.sysobjects
INNER JOIN syscomments ON sys.sysobjects.id = sys.syscomments.id --对应id
WHERE sys.syscomments.text LIKE '%关键字%' --想要查询的关键字
sys.sysobjcets: for each object within the database established, such as conditional constraints, defaults, records, pre-existing rules and processes, each containing a data column.
sys.syscomments: Each database contains the view, rules, defaults, triggers the process, CHECK constraint conditions, constraints, and pre-existing conditions DEFAULT project process. text data row contains the original SQL definition statement.
sys.syscomments.text: the actual text of the SQL definition statement. Search the keywords in the field.
To specify the view (View), pre-existing process (Stored Procedure), scalar functions, data table function .. and so on. Plus conditions sys.sysobjects.type = 'object type'.
SELECT *
FROM sys.sysobjects
INNER JOIN syscomments ON sys.sysobjects.id = sys.syscomments.id --对应id
WHERE sys.syscomments.text LIKE '%关键字%' --想要查询的关键字
AND sys.sysobjects.type = '对象类型' --指定的对象类型
sys.sysobjects type type:
-
AF = aggregate function (CLR)
-
C = CHECK Constraint
-
D = Default or DEFAULT Constraint
-
F = FOREIGN KEY Constraint
-
FN = scalar functions
-
FS = component (CLR) scalar functions
-
FT = component (CLR) data table valued function IF = in-line data table function
-
IT - internal data table
-
K = PRIMARY KEY constraints or conditions UNIQUE
-
Record L =
-
P = pre-existing process
-
PC = component (CLR) stored process
-
R = rule
-
RF = replication stored screening process
-
S = System Data Sheet
-
SN = synonyms
-
SQ = service queue
-
TA = component (CLR) DML trigger process
-
Data table function TF =
-
TR = SQL DML trigger process
-
Data Sheet Type TT =
-
U = user data table
-
View V =
-
X = Extended stored process
For example, to search there 'Name' text in this view, SQL, such as:
SELECT *
FROM sys.sysobjects
INNER JOIN syscomments ON sys.sysobjects.id = sys.syscomments.id --对应id
WHERE sys.syscomments.text LIKE '%Name%' --想要查询的关键字,Name
AND sys.sysobjects.type = 'V' --指定的对象类型,检视(View)
END
Back catalog
Original: Large column [SQL] search for a keyword in SQL Server