How do you programmatically copy an MS SQL 2000 database using C #?

I need to copy multiple tables from one database to another in SQL Server 2000 using C # (VS 2005). The call must be parameterized - I need to be able to pass the name of the database to which I am going to copy these tables.

I could use DTS with parameters, but I cannot find example code that does this from C #.

Alternatively, I could just use

drop table TableName
select * into TableName from SourceDB..TableName

and then restore indexes, etc., but it is really kludgy.

Any other ideas?

Thank!

+3
source share
3 answers

SQL Server 7.0 2000 SQLDMO . SQL Server 2005 SMO. , , , . , , " " .

SQL 2000: SQL-DMO

SQL 2005: SMO: Microsoft SQL Server (SMO)

:

Visual Basic.NET

+3

, SELECT INTO? .

, , , ?

SQL .

+1

You can put the scripts found here (db copy)

http://www.codeproject.com/KB/database/CreateDatabaseScript.aspx

In the app. Just replace the destination. To actually move the database you want, FOLLOW

http://support.microsoft.com/kb/314546

But remember that you must first disable the database.

thank

+1
source

Source: https://habr.com/ru/post/1697931/


All Articles