SQL Copy Table in C#
-
I have a C# program that has a connection to 2 different databases across 2 different SQL servers. How can I easily copy a table and all its contents from one database to another using SQL statements in C# I do not want to use the management studio to perform this and want to do it in my C# program. Any help would be appreciated. Thanks
-
I have a C# program that has a connection to 2 different databases across 2 different SQL servers. How can I easily copy a table and all its contents from one database to another using SQL statements in C# I do not want to use the management studio to perform this and want to do it in my C# program. Any help would be appreciated. Thanks
This may be what you are looking for: http://69.10.233.10/KB/database/GenericCopyTableDataFcn.aspx[^] I used his solution in my project. It worked well. Happy programming!
-
I have a C# program that has a connection to 2 different databases across 2 different SQL servers. How can I easily copy a table and all its contents from one database to another using SQL statements in C# I do not want to use the management studio to perform this and want to do it in my C# program. Any help would be appreciated. Thanks
Solution 1: Take the help of
SSIS
for the task. It is handy and simple. Solution 2: Using
SMO class
, you can create a backup of your database and restore it also. There are plenty of articles in the net explaining how to do the same using SMO. Please have a look Backup and restore SQL databases[^] Hope this helps :)
Niladri Biswas
-
I have a C# program that has a connection to 2 different databases across 2 different SQL servers. How can I easily copy a table and all its contents from one database to another using SQL statements in C# I do not want to use the management studio to perform this and want to do it in my C# program. Any help would be appreciated. Thanks
Try using SqlBulkCopy - google for that and check out the example here http://www.sqlteam.com/article/use-sqlbulkcopy-to-quickly-load-data-from-your-client-to-sql-server[^]