Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / DB Engine / SQL Server / March 2008

Tip: Looking for answers? Try searching our database.

How to create table using another table in SQL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Atenza - 05 Mar 2008 01:39 GMT
hi,

How to create a new tableA from tableB by a single SQL?
I can't find from the book online, i remember that is possbile.

Thanks,
Martin
jason - 05 Mar 2008 01:47 GMT
Providing you don't want the data, you could do this.

select * into tableA
from tableB
where 1=2

Signature

Jason Massie
www: http://statisticsio.com
rss: http://feeds.feedburner.com/statisticsio

> hi,
>
[quoted text clipped - 3 lines]
> Thanks,
> Martin
Rubens - 05 Mar 2008 02:04 GMT
That's a really neat trick!  Why does the table creation happen regardless
of whether there is data inserted?
:-)

Rubens

> Providing you don't want the data, you could do this.
>
[quoted text clipped - 9 lines]
>> Thanks,
>> Martin
jason - 05 Mar 2008 02:27 GMT
SQL creates the table before it checks to see if 1=2 :) In a parallel
universe, it may...

Signature

Jason Massie
www: http://statisticsio.com
rss: http://feeds.feedburner.com/statisticsio

> That's a really neat trick!  Why does the table creation happen regardless
> of whether there is data inserted?
[quoted text clipped - 15 lines]
>>> Thanks,
>>> Martin
Uri Dimant - 05 Mar 2008 06:17 GMT
This technique does not create PK,FK  on target table

> SQL creates the table before it checks to see if 1=2 :) In a parallel
> universe, it may...
[quoted text clipped - 18 lines]
>>>> Thanks,
>>>> Martin
Atenza - 05 Mar 2008 08:54 GMT
thx all

this is useful to create temp table for checking

> This technique does not create PK,FK  on target table
>
[quoted text clipped - 20 lines]
>>>>> Thanks,
>>>>> Martin
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.