Created
May 9, 2012 07:20
-
-
Save hurricanepkt/2642643 to your computer and use it in GitHub Desktop.
Problem with Azure and DBCC InputBuffer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE TRIGGER [dbo].[tbl_Client_Audit_Logging] | |
ON [dbo].[tbl_Client] | |
AFTER INSERT,UPDATE | |
AS | |
BEGIN | |
-- SET NOCOUNT ON added to prevent extra result sets from | |
-- interfering with SELECT statements. | |
SET NOCOUNT ON; | |
-- Insert statements for trigger here | |
IF EXISTS (SELECT * FROM inserted) | |
BEGIN | |
DECLARE @ExecStr varchar(50), @Qry nvarchar(max) | |
CREATE TABLE #inputbuffer | |
( | |
EventType nvarchar(30), | |
Parameters int, | |
EventInfo nvarchar(max) | |
) | |
SET @ExecStr = 'DBCC INPUTBUFFER(' + STR(@@SPID) + ')' | |
INSERT INTO #inputbuffer | |
EXEC (@ExecStr) | |
SET @Qry = (SELECT EventInfo FROM #inputbuffer) | |
INSERT INTO | |
tbl_Client_Audit | |
SELECT | |
SYSDATETIME(), | |
@Qry, | |
inserted.* | |
FROM | |
inserted | |
END | |
END | |
GO |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment