Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2003
    Location
    Romania
    Posts
    70

    Unanswered: 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 english

  2. #2
    Join Date
    Jul 2003
    Location
    The Dark Planet
    Posts
    1,401
    Well .. use xp_cmdshell and echo for the same
    Get yourself a copy of the The Holy Book

    order has no physical Brett in The meaning of a Kaiser . -database data

  3. #3
    Join Date
    Nov 2003
    Location
    Romania
    Posts
    70
    Please an example will be usefull for me...

  4. #4
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    524
    Code:
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •