Question

Is it possible to run a script using Microsoft.SqlServer.Management.Smo?

I am able to generate script using the Microsoft.SqlServer.Management.Smo.Scripter class. I would like to edit it and run it to create copy of database objects.

Thanks.

Was it helpful?

Solution

You can try this. The other option is to use the SQLCommand object.

string script = "create procedure b as select getdate()";
Database db = new Database(new Server("ServerName"), "DBName");
db.ExecuteNonQuery(script);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top