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

Answer Posted / 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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the parse query button used for?

676


What are the disadvantages of merge replication?

846


How to delete exactly duplicate records from a table?

679


How to find the service pack installed? : sql server database administration

615


What are the differences between substr and charindex in sql server.

569






Can you always create a cache of a report?

121


How to create a simple stored procedure in ms sql server?

579


What are the types of containers in ssis?

657


when you create a database how is it stored? : Sql server database administration

550


what are the new features in SSRS?

111


How do we upgrade from SQL Server 6.5 to 7.0 and 7.0 to 2000?

1694


What command do we use to rename a database?

670


What is the Control Flow in SSIS

629


What is merge join?

632


Explain in details security in SQL azure?

103