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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 insert into table with more data
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

219 Posts

Posted - 05/14/2013 :  03:10:46  Show Profile  Send shanmugaraj a Yahoo! Message  Reply with Quote
I need to insert an result into my main table.

Insert into main_table
(country_id, state_id
(SELECT distinct country_id from [dim_country]) ,
(SELECT distinct state_id from [dim_state])

Expected Result
1 | 101
1 | 102
1 | 103
Msg 512, Level 16, State 1, Line 2
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.


Edited by - shanmugaraj on 05/14/2013 03:26:24

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 05/14/2013 :  03:41:37  Show Profile  Reply with Quote

Insert into main_table 
(country_id, state_id
SELECT country_id,state_id
SELECT distinct country_id from [dim_country]
SELECT distinct state_id from [dim_state]

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000