Search This Blog

Friday, September 21, 2007

Dynamic sql to perform a SQL task on a list of tables

EXEC sp_MSforeachtable 'IF ''?'' LIKE ''%tbStaging%'' BEGIN PRINT ''?'' DELETE ? END '

Wednesday, September 19, 2007

Using SQL profiler to trace trigger execution

In Profile Trace add:
SP:StmtCompleted event because that’s where trigger execution appears.

T-SQL Determine Database ID

SELECT name, DB_ID(name) AS DB_ID
FROM master.dbo.sysdatabases
ORDER BY dbid