sententia
Home    Blog

Stored Procedure look up its own name via T-SQL vs hardcoding (@@PROCID)

        INSERT INTO [dbo].[MyTable]
           ([PROCESS_NAME]
           ,[MSG_TYPE]
           ,[MSG_TEXT]
           ,[TRANS_DATE])
        VALUES
           (OBJECT_NAME(@@PROCID)  -- instead of hard coding the name in here.
           ,'INFO'
           ,'Started'
           ,GETDATE());