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.
| Author |
Topic |
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2006-03-07 : 02:18:47
|
i am in a SP(=stored procedures) making a sub query like this :begin transinsert into (a,b,c,d,e)values (2,3,5,(select c,d from table1 where id=3) )commit i recive that a subquery isnt possible only scalar expressions are allowed!what can i do?thnaks i nadvancepelegIsrael -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-03-07 : 02:21:33
|
subquery can only return on column not 2.insert into (a,b,c,d,e)select 2,3,4,c,dfrom table1where id = 3 ----------------------------------'KH' |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-03-07 : 02:22:38
|
| yes coz you specified values, so it's looking for unit values... not result of subquer, imagine how many there are if id=3 returns more than 1 row?try this...insert into (a,b,c,d,e)select 2,3,5,c,d from table1 where id=3--------------------keeping it simple... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-03-07 : 03:16:30
|
That should beinsert into yourTable(a,b,c,d,e)select 2,3,5,c,dfrom table1where id = 3 MadhivananFailing to plan is Planning to fail |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-03-07 : 03:39:49
|
. Thanks Madhivanan----------------------------------'KH' |
 |
|
|
pelegk2
Aged Yak Warrior
723 Posts |
Posted - 2006-03-07 : 05:33:10
|
| thnaks all of uIsrael -the best place to live in aftr heaven 9but no one wan't to go there so fast -:) |
 |
|
|
|
|
|
|
|