I am trying to create a console application that will do several things like stop a service. One of the tasks it must do is drop a database. The code I have come up with is:
string sqlcmd = "sqlcmd –d master –Q drop database test";
ProcessStartInfo ProcessProperties = new ProcessStartInfo();
ProcessProperties.FileName = "cmd.exe";
ProcessProperties.Arguments = sqlcmd;
ProcessProperties.UseShellExecute = false;
Process myprocess = Process.Start(ProcessProperties);
When I run the sqlcmd from the commandline then it deletes the database.
What I am after is passing this to the commandline from my application
sqlcmd -d master -Q "drop database test"
Can someone please help me with that.