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

Can we rewrite subqueries into simple select statements or with joins? Example?

2 Answers   ASD Lab,


How do you implement one-to-one, one-to-many and many-to- many relationships while designing tables?

4 Answers   Credit Suisse, GCU, Symphony, TCS,


How to specify the collation for a character data type in ms sql server?

0 Answers  


What do you mean by authentication modes in sql server?

0 Answers  


create index a on employee(dno) In this,which index was created?

2 Answers  






in a table is b in column k (manikanta,sivananda,muralidhar) i want result like (mnikanta,sivnanda,murlidhar) please slove it

0 Answers  


Tell me about pre-defined functions of sql?

0 Answers   EXL,


How many partitions a clustered index has by default in sql server 2012?

0 Answers  


What does asynchronous call backs means?

0 Answers   Alcatel-Lucent,


How to delete a database in ms sql server?

0 Answers  


how many layers of tcp/ip protocol combined of? : Sql server database administration

0 Answers  


How to enter unicode character string literals in ms sql server?

0 Answers  


Categories