Jader Dias Jader Dias - 10 months ago 53
C# Question

How to duplicate a SQL Server 2000 table programatically using .NET 2.0?

I want to backup a table saving the copy in the same database with another name. I want to do it programatically using .NET 2.0 (preferably C#). Someone can point me what should I do?


Just send this query to the server:

SELECT * INTO [BackupTable] FROM [OriginalTable]

This will create the backup table from scratch (an error will be thrown if it already exists). For large tables be prepared for it to take a while. This should mimic datatypes, collation, and NULLness (NULL or NOT NULL), but will not copy indexes, keys, or similar constraints.

If you need help sending sql queries to the database, that's a different issue.