mike

mike

  • NA
  • 25
  • 0

Query success in MMS, failure in code

Mar 1 2010 6:21 AM

Hey,
I have two databases and i use schema compare in Visual Studio 2008 to generate a script to upgrade one to the other.  Now i have written some code which needs to execute this script on a database.   If i create the script, and then open up Management Studio and paste it in and run it,  the query executes successfully.  However,  if i let my code do it an error is returned;
"Incorrect syntax near the keyword Go",  "Incorrect syntax near the keyword SET"  etc.
Does anyone know why these two methods of running the same script produce different results?  Once i've connected to the server and started the transaction i simply use;  (any pointers on this would be great!!)
 

SqlCommand command = new SqlCommand(script, conn, tn);
command.ExecuteNonQuery();

Answers (1)