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 |
|
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2011-06-05 : 16:18:49
|
I am just not seeing the problem with this.Keep getting the error:Msg 116, Level 16, State 1, Line 18Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.Msg 109, Level 15, State 1, Line 3There are more columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.INSERT INTO UserAccount ( UserName, PasswordHash, Salt, Email ) VALUES ( (SELECT UserName, PasswordHash, Salt, Email FROM AccessRequest) ) I tried without the extra brackets in the values clause as well but with no luck.Any suggestions?Thanks,Zath |
|
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2011-06-05 : 16:33:27
|
If you are trying to insert the values which is the result of a select, you don't need the values keyword. So it would be like this:INSERT INTO UserAccount ( UserName, PasswordHash, Salt, Email ) SELECT UserName, PasswordHash, Salt, Email FROM AccessRequest This would insert one row into UseAccount table for every row in AccessRequest |
 |
|
|
Zath
Constraint Violating Yak Guru
298 Posts |
Posted - 2011-06-05 : 16:41:18
|
| Ok, I see. I didn't need the VALUES keyword.And yes, there is a WHERE in the SELECT.I just shortened the sql for an easy read.THANKS!!!! |
 |
|
|
|
|
|
|
|