Home Forums SQL Server 2008 T-SQL (SS2K8) trigger to call a program to write a text file onto a folder in the server RE: trigger to call a program to write a text file onto a folder in the server

  • hi

    I just have an update that we don't need to delete the record from the table as long as every time a record inserted can be write to a text file for the other side to consume. So, i did a quick test like this and have access denied issue.

    exec master.xp_cmdshell 'echo hello > c:\file.txt' which try to write to the c drive on the sql server.

    but if i quality it as

    exec master.xp_cmdshell 'echo hello > \\myPC\c$\file.txt'

    The issue is when i log on to sql server, i can add/write/mod files from c drive. Any reason? How to i use "execute as" statement?

    thx, Ted.