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

Explain the steps to use transact-sql cursor?

0 Answers  


Comment,Datatypes are unlimited

0 Answers   IBM,


What are logical database components? : SQL Server Architecture

0 Answers  


How would you Update the rows which are divisible by 10, given a set of numbers in column?

3 Answers  


How to encrypt Strored Procedure in SQL SERVER?

0 Answers  






How to generate create procedure script on an existing stored procedure?

0 Answers  


How to include date and time values in sql statements?

0 Answers  


What are the steps to take to improve performance of a poor performing query? : sql server database administration

0 Answers  


Define tool Manage Statistics in SQL Server 2000 query ?

0 Answers   NA,


Will count(column) include columns with null values in its count?

0 Answers  


How to select some specific rows from a table in ms sql server?

0 Answers  


Why olap is used?

0 Answers  


Categories