G
Guest
Ok...here we go...
I am trying to manually run an SQL server back up job from c#. Here is a
snippet of my code to begin the process:
string strSQL = "USE msdb " +
"\n if exists(select * from sysjobs_view where name = 'TempBackupJob') " +
"\n EXEC sp_delete_job @job_name = 'TempBackupJob' " +
"\n GO";
newDB.Command(strSQL);
This command exceptions with an "Incorrect syntax near 'GO'".
Now, when I put the EXACT same query into Query Analyzer like this:
USE msdb
if exists(select * from sysjobs_view where name = 'TempBackupJob')
EXEC sp_delete_job @job_name = 'TempBackupJob'
GO
the command executes without any errors.
Is there something I'm missing with newline characters? I also tried using
\r\n instead of just \n to separate the lines...that didn't work either.
Any help would be greatly appreciated.
I am trying to manually run an SQL server back up job from c#. Here is a
snippet of my code to begin the process:
string strSQL = "USE msdb " +
"\n if exists(select * from sysjobs_view where name = 'TempBackupJob') " +
"\n EXEC sp_delete_job @job_name = 'TempBackupJob' " +
"\n GO";
newDB.Command(strSQL);
This command exceptions with an "Incorrect syntax near 'GO'".
Now, when I put the EXACT same query into Query Analyzer like this:
USE msdb
if exists(select * from sysjobs_view where name = 'TempBackupJob')
EXEC sp_delete_job @job_name = 'TempBackupJob'
GO
the command executes without any errors.
Is there something I'm missing with newline characters? I also tried using
\r\n instead of just \n to separate the lines...that didn't work either.
Any help would be greatly appreciated.