Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Using Select to copy a table

Author  Topic 

WonkyGibbon
Starting Member

3 Posts

Posted - 2005-04-21 : 05:40:56
Hi there,

I'm writing a module that as part of it's job has to make a backup copy of a bunch of tables prior to altering them. Becuase the module has to be useable Oracle, DB2 & SQLServer - we're using ODBC and SQL to do this.

For Oracle & DB2 - the following SQL works :
CREATE TABLE BackupFred AS SELECT * FROM Fred

The important point being that I don't have to know about the structure of "Fred", to do this.

Now, I just can't see how to do this in SQL Server - any pointers would be a huge help.

Many thanks

satishdg
Starting Member

10 Posts

Posted - 2005-04-21 : 05:57:45
Hi,

see this link

http://www.databasejournal.com/features/mssql/article.php/2206571

Satish
Go to Top of Page

WonkyGibbon
Starting Member

3 Posts

Posted - 2005-04-21 : 06:46:04
Obviously - being cross platform, we can't use a stored procedure - but it's possible that the following (extracted from your link) may work - I'll have to test ...

select * into BackupDBName.dbo.Fred from Fred

or maybe even

select * into BackupFred from Fred
Go to Top of Page

WonkyGibbon
Starting Member

3 Posts

Posted - 2005-04-21 : 06:49:44
Yes - that works.

Thanks guys.
Go to Top of Page
   

- Advertisement -