Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Administration - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 6525

return error for sqlcmd in sql agent job

$
0
0
I have a simple task to export a table to a flat file on network share.so I schedules a sql agent job that does below: sqlcmd -S myserver -d mydb -E -Q "set nocount on;select studentID, guardian_contact_id from [dbo].[ParentReferral]" -o "\\myotherserver\data\import\myflatfile.dat" -W -w 700 -h-1 -s","THe job type is Operating system, cmdexecI found today the job succeeded, but when I opened the flat file, on top of the file there it error: login account which is the SQL agent service account failed to login to the database, even so, it still generated the data.It is strange, I thought SQL agent account by default has sysadmin permissions, so should be able to. Then I specifically added the permission, it works now.My question now is how to let the SQL agent job to return job failed for about case if it fails? Should I just add a -b switch?Thanks,

Viewing all articles
Browse latest Browse all 6525

Trending Articles