I have this in all of my stored procedures. Its come in very handy for me.The part in blue you have to modify dependent on the input variables /***************************************************** Start Stored Procedure Tracking *****************************************************/ Declare @runId uniqueidentifier, @execStr varchar(4000) Select @runId = newId() Select @execStr = convert(varchar,db_Name()) + '.dbo.' + isnull((Select name from sysobjects where id = @@procId),'unknown') + ' ' + isnull(''''+@varchar+'''','null') + ', ' + isnull(convert(varchar,@int),'null') + ', ' + isnull(''''+convert(varchar,@date,121)+'''','null') + ', ' + isnull(convert(varchar,@bit),'null') Insert Into netprofit.dbo.proc_log_detail Select runId = @runId, procId = isnull(@@ProcId,0), starttime = getdate(), null, @execStr /***************************************************** End Stored Procedure Tracking *****************************************************/ --Your Stored Procedure Select [Corey Says] = 'Hi' /***************************************************** Start Stored Procedure Tracking *****************************************************/ Update netprofit.dbo.proc_log_detail Set endtime = getdate() where runId = @runId /***************************************************** End Stored Procedure Tracking *****************************************************/and the table used for storage:CREATE TABLE dbo.proc_log_detail ( runId uniqueidentifier NOT NULL , procId int NOT NULL , starttime datetime NOT NULL , endtime datetime NULL , execStr varchar (4000) NULL )
Corey
Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now."