User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 426,851 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,115 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 11464 | Replies: 1
Reply
Join Date: Feb 2005
Posts: 175
Reputation: Letscode is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
Letscode's Avatar
Letscode Letscode is offline Offline
Junior Poster

INSERT CLAUSE using SUB-QUERY

  #1  
Oct 18th, 2005
I'm trying to populate a table from a sub-query.

CREATE TABLE test
(
ID int
)


INSERT INTO test
VALUES (SELECT [Customer Id] 
FROM   [Customers])


QUESTION:
I know you can do this in ORACLE but Is something like this possible in T-SQL.

I can also write something like this in SQL which achieves the same result but I will lose the datatype,

SELECT [Customer Id] 
INTO test
FROM   [Customers]


Any suggestions is greatly appreciated.
Save White Tiger
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2005
Posts: 175
Reputation: Letscode is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
Letscode's Avatar
Letscode Letscode is offline Offline
Junior Poster

Re: INSERT CLAUSE using SUB-QUERY

  #2  
Oct 24th, 2005
[HTML]
INSERT INTO test
(SELECT [Customer Id]
FROM [Customers])
[/HTML]

Works fine.
Save White Tiger
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 9:39 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC