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

If we shrink the Databse and Files, how much size is decreased?

1 Answers   TCS,


What is a sub-query? When would you use one?

3 Answers  


What is the maximum size of a dimension? : sql server analysis services, ssas

0 Answers  


What do you mean by COLLATION?

4 Answers   ABC, BirlaSoft,


How many databases instances are there in sql server 2000?

0 Answers  






I have a table EMP in which the values will be like this EmpId Ename Sal DeptId 11 Ram 10000 10 11 Ram 10000 10 22 Raj 20000 20 22 Raj 20000 20 33 Anil 15000 30 33 Anil 15000 30 I want to delete only duplicate Rows. After Delete I want the output like this EmpId Ename Sal DeptId 11 Ram 10000 10 22 Raj 20000 20 33 Anil 15000 30

13 Answers   DELL,


Is mysql better than sql server?

0 Answers  


What are the difference between clustered and a non-clustered index?

0 Answers  


What does it mean to have quoted_identifier on? What are the implications of having it off?

2 Answers  


What are trace flags?

0 Answers  


what is lazy writer?

1 Answers   Wipro,


How do I partition a table in sql server?

0 Answers  


Categories