views:

85

answers:

1

Hi,

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.

+1  A: 

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);
doug_w