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 |
What are the steps you will take to improve the performance of a poor performing query?
What does it mean to normalize data?
What samples and sample databases are provided by microsoft?
What are subqueries in sql server? Explain its properties.
How to modify the underlying query of an existing view?
how to find nth highest salary
103 Answers Cognizant, IBM, NexGen, Oracle,
What is the use of custom fields in report?
How to locate and take substrings with charindex() and substring() functions?
What does sql server mean?
Which is faster statement or preparedstatement?
In which tcp/ip port does sql server run? Can it be changed?
What is log shipping?
Oracle (3259)
SQL Server (4518)
MS Access (429)
MySQL (1402)
Postgre (483)
Sybase (267)
DB Architecture (141)
DB Administration (291)
DB Development (113)
SQL PLSQL (3330)
MongoDB (502)
IBM Informix (50)
Neo4j (82)
InfluxDB (0)
Apache CouchDB (44)
Firebird (5)
Database Management (1411)
Databases AllOther (288)