SQLTeam.com | Weblogs | Forums

Issues with SQL Trigger

I have created a SQL Trigger as below.

create trigger testtrigger on testdb

for insert

as

declare @sql varchar(8000)

SELECT @sql = 'bcp "select * from testdb" queryout c:\output.txt -c -t -T -S localhost'

exec xp_cmdshell @sql

go

But when a row inserted in the testdb, the text file is created, but there is no content. Can someone please help me to resolve this.

Because row is inserted after trigger probably. If you insert a new record row #1 probably will show up in the file

I have tried inserting many rows. But there was nothing in the file.

Look in the SQL Server error log. Likely something is failing. Perhaps you don't have authority to write to C:<filename>.

The bcp command is working when I run it directly in the command prompt.

hi

please see below link ..

Please Google Serach

Thanks Harish.

Do I have an option to see what's happening when the trigger is executing to know the exact error and on which step it is failing.