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
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 |
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 |
Explain the steps to use transact-sql cursor?
Comment,Datatypes are unlimited
What are logical database components? : SQL Server Architecture
How would you Update the rows which are divisible by 10, given a set of numbers in column?
How to encrypt Strored Procedure in SQL SERVER?
How to generate create procedure script on an existing stored procedure?
How to include date and time values in sql statements?
What are the steps to take to improve performance of a poor performing query? : sql server database administration
Define tool Manage Statistics in SQL Server 2000 query ?
Will count(column) include columns with null values in its count?
How to select some specific rows from a table in ms sql server?
Why olap is used?