INSERT CLAUSE using SUB-QUERY

Please support our MS SQL advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2005
Posts: 175
Reputation: Letscode is an unknown quantity at this point 
Solved Threads: 6
Letscode's Avatar
Letscode Letscode is offline Offline
Junior Poster

INSERT CLAUSE using SUB-QUERY

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

  1. CREATE TABLE test
  2. (
  3. ID int
  4. )
  5.  
  6.  
  7. INSERT INTO test
  8. VALUES (SELECT [Customer Id]
  9. 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,

  1. SELECT [Customer Id]
  2. INTO test
  3. FROM [Customers]

Any suggestions is greatly appreciated.
Save White Tiger
Reply With Quote Quick reply to this message  
Join Date: Feb 2005
Posts: 175
Reputation: Letscode is an unknown quantity at this point 
Solved Threads: 6
Letscode's Avatar
Letscode Letscode is offline Offline
Junior Poster

Re: INSERT CLAUSE using SUB-QUERY

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

Works fine.
Save White Tiger
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC