Vous êtes sur la page 1sur 1

HOW TO: Find a specific text or string in all database objects - Stored Procedures, Views, Triggers, functions, etc

in a database in SQL Server #SQLQUERY


#SQLTIPS #SQLQUERY #SQLINTERVIEWQUESTIONS #SQL2005 #SQLSERVER SELECT DISTINCT o.name AS ObjectName, CASE o.xtype WHEN 'C' THEN 'CHECK constraint' WHEN 'D' THEN 'Default or DEFAULT constraint' WHEN 'F' THEN 'FOREIGN KEY constraint' WHEN 'FN' THEN 'Scalar function' WHEN 'IF' THEN 'In-lined table-function' WHEN 'K' THEN 'PRIMARY KEY or UNIQUE constraint' WHEN 'L' THEN 'Log' WHEN 'P' THEN 'Stored procedure' WHEN 'R' THEN 'Rule' WHEN 'RF' THEN 'Replication filter stored procedure' WHEN 'S' THEN 'System table' WHEN 'TF' THEN 'Table function' WHEN 'TR' THEN 'Trigger' WHEN 'U' THEN 'User table' WHEN 'V' THEN 'View' WHEN 'X' THEN 'Extended stored procedure' ELSE o.xtype END AS ObjectType FROM syscomments c INNER JOIN sysobjects o ON c.id=o.id LEFT JOIN sysobjects p ON o.Parent_obj=p.id WHERE c.text LIKE '%ursearchtext%' --enter ur search text here ORDER BY ObjectName