Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Create Database

Author  Topic 

Daffyydd
Starting Member

2 Posts

Posted - 2007-08-01 : 04:52:36
Is it possible to create a database using the Select query. For Example

Create Database #temp(select * from Sales)

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-08-01 : 05:25:49
1 No
2 You can create a table using a Select query
Select * into #temp from Sales


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Daffyydd
Starting Member

2 Posts

Posted - 2007-08-01 : 06:01:56
So it means i have to create the table #temp first before selecting into.
Go to Top of Page

pootle_flump

1064 Posts

Posted - 2007-08-01 : 07:16:11
quote:
Originally posted by Daffyydd

So it means i have to create the table #temp first before selecting into.

No. Selecting into syntax creates the table for you. Insert into requires the table exists already. You are, however, typically advised to not use select into where possible especially for any long running queries.
Go to Top of Page

rmiao
Master Smack Fu Yak Hacker

7266 Posts

Posted - 2007-08-01 : 11:47:26
You'll not get keys nor indexes on target table when create table this way.
Go to Top of Page
   

- Advertisement -