Thursday, March 8, 2012

Another easy question

I want to use a trigger (FOR DELETE)
For example

CREATE TRIGGER test ON [Table_1]
FOR DELETE
AS
..... export to a text file someting like this:
Date + TableName + UserName + Record with will be deleted

How can I export a single record to a text file ?

Sorry for my englishWell .. use xp_cmdshell and echo for the same|||Please an example will be usefull for me...|||CREATE TRIGGER test ON MyTable
FOR DELETE
AS
BEGIN
DECLARE @.MyString varchar(255)

SELECT @.MyString=
"ECHO "
+convert(varchar(20), getdate(), 0)
+" MyTable "
+ convert(varchar(10), MyKey)
+ user_name()
+ ">> C:\temp\log.txt"

exec xp_cmdshell @.myString
END

No comments:

Post a Comment