Declare @SearchString varchar(50) = 'kotak_CMS..sf_subscriber'
Get Sp name with type and defination from sys.sql_modules and sys.objects tables
SELECT [Scehma]=schema_name(o.schema_id), o.Name, o.type, m.definition
FROM sys.sql_modules m
INNER JOIN sys.objects o
ON o.object_id = m.object_id
WHERE m.definition like '%'+@SearchString+'%'
Get Sp name from syscomment and sysobjects table
SELECT DISTINCT so.name
FROM syscomments sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%'+@SearchString+'%'
Get Sp name from sys.procedures table
SELECT Name
FROM sys.procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%'+@SearchString+'%'
GO
Get Sp name with type and defination from sys.sql_modules and sys.objects tables
SELECT [Scehma]=schema_name(o.schema_id), o.Name, o.type, m.definition
FROM sys.sql_modules m
INNER JOIN sys.objects o
ON o.object_id = m.object_id
WHERE m.definition like '%'+@SearchString+'%'
Get Sp name from syscomment and sysobjects table
SELECT DISTINCT so.name
FROM syscomments sc
INNER JOIN sysobjects so ON sc.id=so.id
WHERE sc.TEXT LIKE '%'+@SearchString+'%'
Get Sp name from sys.procedures table
SELECT Name
FROM sys.procedures
WHERE OBJECT_DEFINITION(OBJECT_ID) LIKE '%'+@SearchString+'%'
GO
Find Column name in database tables
SELECT c.name AS 'ColumnName'
,t.name AS 'TableName'
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE c.name LIKE '%Branch%'
ORDER BY TableName ,ColumnName;
GOFind Text in All Store Procedure
SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%(7)%'
AND ROUTINE_TYPE='PROCEDURE'
GO
No comments:
Post a Comment