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 |
sushant17284
Starting Member
12 Posts |
Posted - 2010-01-27 : 03:10:54
|
I have a problem with an SQL server query.The error that I am getting is the subquery return more than one value.This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.The following is my query : I have a temporary report table called ReportsAdditionalCommentI am doing an update in this temp table and selecting additional comments.Now the problem is when the following statement runs inside the stored procedure it returns the above error of subquery returned more than one value.Obviously, I can make out since I am setting out into one variable , it will not accept if the inner query returns more than one row.But I don't know how to modify the SET part of this query so that it can return more than one Row.I need to have multiple comments returned and set in ADD_COMMENTS.UPDATE #TEMP_ReportsAdditionalCommentSET ADD_COMMENTS = (SELECT RE.REMARKS FROM ReviewEvent RE WHERE RE.PROJECT_ID = @PROJ_ID AND RE.REPOINT_ID = @REPOINT_ID AND RE.REVIEW_DATE = @REVIEW_DATE ) The type of ADD_COMMENTS is VARCHAR(1000).I hope I have explained it clearly.I seemed to be stuck on this for the last two days and since I am a novice in SQL , I really don't know what could be the solution.By the way the inner SQL query executes perfectly and returns two rows but I don't know how to set up multiple rows in ADD_COMMENTS .Please Help. |
|
Kristen
Test
22859 Posts |
Posted - 2010-01-27 : 03:15:18
|
Do you want to concatenate the multiple results returned from the inner Sub-Query? Or the single Remark from the most recent Review Date? or something else? |
 |
|
sushant17284
Starting Member
12 Posts |
Posted - 2010-01-27 : 03:43:54
|
Well It would be fine with me to concatenate the multiple results returned from the subquery.But,In an ideal situation I would like to know ...Is there any way of setting multiple rows into single variable ADD_COMMENTS ??.But at this point of time, concatenating the multiple results should be fine with me as I will move a little forward.Thanks for your reply Kristen. |
 |
|
sushant17284
Starting Member
12 Posts |
Posted - 2010-01-27 : 03:49:04
|
Is it possible to concatenate the multiple rows and add a delimiter in SQL so that it would be an easier task to separate them at the client side again ?? |
 |
|
Kristen
Test
22859 Posts |
Posted - 2010-01-27 : 04:34:51
|
"Is there any way of setting multiple rows into single variable ADD_COMMENTS"Can you explain what you mean by this - i.e. how that is different to concatenating them with a delimiter?Normally you would have a Parent Table (Projects) and a child table (ProjectRemarks) where there is a one-to-many relationship between the data.Concatenating them, with a delimiter, is normally just for "presentation" purposes. |
 |
|
|
|
|
|
|