| Author |
Topic |
|
TJ
Posting Yak Master
201 Posts |
Posted - 2002-11-06 : 11:36:02
|
This queryupdate irsdata set procstat = 'I9'where ((select charindex('[007]', frmdata, 5) from tempbatch where left(frmheader, 3) = 'RET')<> '30401') and (ntsbatch = 'zzp30401')is returning the error: Server: Msg 512, Level 16, State 1, Line 1Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. The statement has been terminated. Will someone please tell me what I'm doing incorrectly and give me pointers on how to correct it? There may be one record that meets the subquery selection criteria, or many. Thanks!Teresa |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2002-11-06 : 11:42:59
|
| You're attempting to compareselect charindex('[007]', frmdata, 5) from tempbatch where left(frmheader, 3) = 'RET'Against '30401'You can't do this because there could be any number of rows that meet that criteria.What are you trying to do with this query? |
 |
|
|
TJ
Posting Yak Master
201 Posts |
Posted - 2002-11-06 : 11:50:22
|
quote: What are you trying to do with this query?
I need all 'RET' records that do not have a '30401' in their frmdatacolumn to fail. The 'batch' of records may have five records or 50,with one of them being a 'ret' or many of them being a 'ret'.Thanks for responding so quickly!TeresaEdited by - tj on 11/06/2002 11:51:08 |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2002-11-06 : 12:09:24
|
quote:
quote: What are you trying to do with this query?
I need all 'RET' records that do not have a '30401' in their frmdatacolumn to fail. The 'batch' of records may have five records or 50,with one of them being a 'ret' or many of them being a 'ret'.Thanks for responding so quickly!TeresaEdited by - tj on 11/06/2002 11:51:08
Okay but you are updating irsdata and looking at tempbatch, so I'm not sure how these two relate to each other. |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2002-11-06 : 12:14:04
|
| You may (at a guess) need something likeUPDATE irsdataset procstat = 'I9'from irsdata left outer join tempbatch on something = something and left(tempbatch.frmheader, 3) = 'RET' and patindex ('30401',frmdata) <> 0where tempbatch.frmheader is null |
 |
|
|
TJ
Posting Yak Master
201 Posts |
Posted - 2002-11-06 : 12:14:34
|
quote: Okay but you are updating irsdata and looking at tempbatch, so I'm not sure how these two relate to each other.
Yes. I'm comparing irsdata to tempbatch and updating irsdata.Teresa |
 |
|
|
mr_mist
Grunnio
1870 Posts |
Posted - 2002-11-06 : 12:22:08
|
quote:
quote: Okay but you are updating irsdata and looking at tempbatch, so I'm not sure how these two relate to each other.
Yes. I'm comparing irsdata to tempbatch and updating irsdata.Teresa
I'd try out what I posted above as a SELECT to see if you get the rows you are looking for in the results. You just need to figure out what the something = something join is between irsdata and tempbatch, which is the bit I can't tell. |
 |
|
|
TJ
Posting Yak Master
201 Posts |
Posted - 2002-11-06 : 12:42:34
|
quote: I'd try out what I posted above as a SELECT to see if you get the rows you are looking for in the results. You just need to figure out what the something = something join is between irsdata and tempbatch, which is the bit I can't tell.
I've been working on this code while we posted back and forth.update irsdata set procstat = 'I9'from irsdata inner join (select irsdataid,ntsbatch, frmheader, substring(frmdata,(charindex('[007]', frmdata)+ 12), 5)as batch from tempbatch mb where (left(mb.frmheader, 3) = 'RET' and right(mb.frmheader, 4) = 'pg01'))as mb on irsdata.ntsbatch = mb.ntsbatch where (irsdata.ntsbatch = 'zzp30401') and batch <> '30401'I was finally able to get it work. Thanks again for your assistance. Best regards,TeresaEdited by - tj on 11/06/2002 12:43:17 |
 |
|
|
|