How can I create a table from another table without copying any values from the old table?

Answers were Sorted based on User's Feedback



How can I create a table from another table without copying any values from the old table?..

Answer / mohammadali.info

CREATE TABLE new_table
AS (SELECT * FROM old_table WHERE 1=2);

For example:

CREATE TABLE suppliers
AS (SELECT * FROM companies WHERE 1=2);

This would create a new table called suppliers that included all columns from the companies table, but no data from the companies table.

Is This Answer Correct ?    7 Yes 3 No

How can I create a table from another table without copying any values from the old table?..

Answer / amit kumar sharma

Select * into newTable From oldTable where 1=2

The where condition 1=2 will never get true, so only the
column of table will appear and get copied to newTable.

If we remove the where condition table with data will copy
to newtable.

Is This Answer Correct ?    3 Yes 0 No

How can I create a table from another table without copying any values from the old table?..

Answer / arun

Select top 0
into newtable
from oldtable

Is This Answer Correct ?    3 Yes 2 No

Post New Answer

More SQL Server Interview Questions

Difference between DELETE and TRUNCATE?

0 Answers   TCS,


What is executereader?

0 Answers  


How to delete duplicate records from a table?(for suppose in a table we have 1000 Records in that we have 200 duplicate Records , so ,how to findout that duplicate Records , how to delete those Records and arranged into sequence order? one more thing that there is no primary key at all)

5 Answers   Infosys, McAfee,


What is the Query of getting last 10 transaction Reports (like insert, update, Delete Data from Tabele) ?

4 Answers   Wipro,


how would you improve etl (extract, transform, load) throughput?

0 Answers   LinkedIn,






What is BCNF? How is it better than 2NF & 3NF?

0 Answers   Essar,


What are distributed partitioned views?

0 Answers  


how do u find least salary in a table

4 Answers  


How does index makes search faster?

0 Answers   QuestPond,


A left outer join B B right outer join A gives the same result then what is the use of two?

1 Answers  


What is ms sql server reporting services?

0 Answers  


When we can say that is in BCNF?

3 Answers   BitWise,


Categories