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

Explain indexes disadvantages?

556


How column data types are determined in a view?

540


Where to find ntwdblib.dll version 2000.80.194.0?

562


What are the differences between sql server and mysql.

536


How does SSIS(Sql Server Integration Services) deffer from DTS(Data Transformation Services)?

604






What are .mdf files?

526


Is it ok to shrink transaction log?

521


Do you know how to make remote connection in database?

560


What are the operating modes in which database mirroring runs?

613


Why main is user defined function?

573


What is the difference between lock, block and deadlock? : sql server database administration

576


How to query multiple tables jointly?

562


What is the cartesian product of table?

553


What are the types of sql server?

523


How can you find out which stored procedures are recompiling?

518