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)
 SQL QUERIES

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-11-02 : 08:12:59
AMARENDRA writes "HOW TO CREATE A TABLE WITHOUT COPYING ITS DATA FROM A TABLE?"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-11-02 : 08:14:06
One of the methods is

Select * into newTable from OldTable where 1=0

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2005-11-02 : 08:14:23
SELECT TOP 0 * INTO newTable FROM myTable

or

SELECT * INTO newTable FROM myTable WHERE 1<>1

This will only copy column names and data type. Constraints, keys, and indexes will not be copied. To copy those you'd have to generate the table's script using Enterprise Manager or programming a SQL-DMO Script method.
Go to Top of Page
   

- Advertisement -