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
What is policy based management (pbm)? : sql server database administration
What are different types of constraints?
What happens if ntwdblib.dll is missing on your machine?
Are all views updatable ?
Due to some maintenance being done, the sql server on a failover cluster needs to be brought down. How do you bring the sql server down?
How to set a database state to offline in ms sql server?
Do you know what are acid properties of transaction?
What is an example of a primary key?
Do you know how to implement service broker?
Why would you call update statistics?
What do you mean by an execution plan?
Can truncate be rolled back?
How to include date and time values in sql statements?
Explain microsoft sql server functions?
How do I view a script in sql server?