-- content of store procedure
sp_helptext 'dbo.proc_name'
-- which store procedure ran and when
SELECT DB_NAME(database_id)
,OBJECT_NAME(object_id,database_id)
,cached_time
,last_execution_time
,execution_count
FROM sys.dm_exec_procedure_stats order by last_execution_time DESC
-- search for stored proc which contains text you are searching for
SELECT ROUTINE_NAME, ROUTINE_DEFINITIONFROM INFORMATION_SCHEMA.ROUTINES WHERE ROUTINE_DEFINITION LIKE '%your search text%' AND ROUTINE_TYPE='PROCEDURE'
-- find tables in database which matches our criteria
DECLARE @SelectCol1nvarchar(60) insert into @tblNames (name) SELECT name FROM sys.databases where name like '0r'
How to enable cdc : record keeping in database
use master go select [name], database_id, is_cdc_enabled from sys.databases go use [databasename] go exec sys.sp_cdc_enable_db go
select * from [dbname].[dbo].[tblMain]
-- ALTER TABLE [dbname ].[dbo].[tblMain] ADD [colName] bigint; --add column