I have an insert trigger that is working fine. I have a need to export the primary key value that was inserted into the table to a text file. My attempts thus far have resulted in an error.
Here is the code:
BEGIN
DECLARE @MySql varchar(1000)
SELECT @MySql = 'osql -Q "SELECT NewRec_id FROM inserted" -E -o E:\SQLData\Backups\temp\data.txt'
EXEC xp_cmdshell @MySql
END
And here is the error that is getting exported to the above txt file:
Msg 208, Level 16, State 1, Server XXSPR40, Line 1
Invalid object name 'inserted'.
This is a third party application so we are really limited to what we can do. The above code is at the end of the the existing insert trigger. But where I put it in the existing code has resulted in the same error each time. I have enabled xp_cmdshell.
Thoughts?
Thanks in advance
Lee
Here is the code:
BEGIN
DECLARE @MySql varchar(1000)
SELECT @MySql = 'osql -Q "SELECT NewRec_id FROM inserted" -E -o E:\SQLData\Backups\temp\data.txt'
EXEC xp_cmdshell @MySql
END
And here is the error that is getting exported to the above txt file:
Msg 208, Level 16, State 1, Server XXSPR40, Line 1
Invalid object name 'inserted'.
This is a third party application so we are really limited to what we can do. The above code is at the end of the the existing insert trigger. But where I put it in the existing code has resulted in the same error each time. I have enabled xp_cmdshell.
Thoughts?
Thanks in advance
Lee