What .net library to use to execute a sql server ALTER script?
I am writing a small .net utility, that needs to iterate through all databases on a server, and run a sql scri开发者_开发百科pt that alters each database.
Presumably, I'll need to connect to the SQL Server using the "sa" user, and then execute the ALTER script in a foreach loop, using the database name to determine whether the script should be applied to each DB.
What .NET library would be most appropriate for DDL transformations like this?
I'd like to have the ALTER script in its own text file.
Would this just be standard ADO.NET ?
Yes, you could use just standard ADO.Net or pretty much any library that let's you send direct sql to the server. Personaly, I use Enterprise Library, but it really doesn't matter.
Regarding the other items. I would never use the SA account from any application. Instead you should just define a user account and grant it the rights it needs. Generally speaking this account should be limited to just this database and just for this application.
I believe the SMO .net library would be the right tool for the job.
http://msdn.microsoft.com/en-us/library/ms162169.aspx
精彩评论