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 beast way to write CTE in SQL Server ?

761


What is a matrix in ssrs?

119


What is difference between oltp and olap?

780


How to get a list of columns in a view using "sys.columns" in ms sql server?

723


What is the current pricing model of SQL Azure?

98






What is Federation Root Database?

100


what are the reporting service components in SSRS?

139


Can two different columns be merged into single column? Show practically?

820


Explain ranking functions?

779


code to create procedure for taking databse backup in sql server or i have the query for it but what it's query returns means i want to show on my jsp that the databse backup has been taken on the basis of that return value.does it returns 0 or 1.wat is the code for that

1969


List types of tables in SQL Azure?

120


When would you use sql joins?

688


Suppose i have a table that contains 5 columns like col1,col2...colm5.I want to import only two column through BCP utility.How to do same through BCP in sybase.

2170


What is partition index in sql server?

798


please differentiate between delete and truncate?

733