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
SQLQueriesCollection is blog for all sql queries in SqlServer at one place.SQL,SQL Query,SQL Queries,SQL Query Code,SQL Query Example,SQL Query Syntax,Basic Sql Queries,Query,SQL Examples,SQL Basic Queries,Structured Query Language.
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