How Do You Copy A Ms Sql 2000 Database Programmatically Using C#?
Solution 1:
For SQL Server 7.0 and 2000, we have SQLDMO for this. For SQL Server 2005 there is SMO. This allows you do to pretty much everything related to administering the database, scripting objects, enumerating databases, and much more. This is better, IMO, than trying a "roll your own" approach.
SQL 2000: Developing SQL-DMO Applications
SQL 2005: Here is the SMO main page: Microsoft SQL Server Management Objects (SMO)
Here is the Transfer functionality: Transferring Data
How to: Transfer Schema and Data from One Database to Another in Visual Basic .NET
Solution 2:
If the destination table is being dropped every time then why not do SELECT INTO? Doesn't seem like a kludge at all.
If it works just fine and ticks all the requirements boxes why create a days worth of work growing code to do exactly the same thing?
Let SQL do all the heavy lifting for you.
Solution 3:
You could put the scripts (copy db) found here
http://www.codeproject.com/KB/database/CreateDatabaseScript.aspx
Into an application. Just replace the destination. To actually move the entite database, FOLLOW
http://support.microsoft.com/kb/314546
But remember, the database has to be taken offline first.
Thanks
Post a Comment for "How Do You Copy A Ms Sql 2000 Database Programmatically Using C#?"