SQL Query to copy structure of one table to another table in SQL Server.
Syntax: Select * into Newtable from Oldtable where 1=2
Ex: Select * into emp1 from emp where 1=2
The above query copies only structure(not data) of emp to emp1.
SQL Query to get structure of table
Subscribe to:
Post Comments (Atom)
4 comments:
This query doesn't works because emp1 table doesn't exists.
Correct One is:
create table emp1 as select * from emp where 1=2;
-----
Thanks n regards
Nagalakshmi.
Select * into emp1 from emp where 1=2
This query will work.even if emp1 table is not their after executing this query emp1 table will be created.
Check once again.
select * into emp1 from emp where 1=2
this query wroks ! thats cool trick..thanks !!!
Select * into emp1 from emp where 1=2
this query will not work for mysql as mysql does not support 'SELECT * INTO'.
Regards,
shilpa vk
Post a Comment