Link to home
Start Free TrialLog in
Avatar of damixa
damixaFlag for Denmark

asked on

Fix in a Sql Statement for Sql Server 2008

I have some code. What I am trying to do is update a certain field to the max + 1

this is the code  that I have
 
update tblBNKrecon
set groupedpmtid = (MAX(GroupedPmtID)+1), newdesc = 'FEHBP' 
where groupedpmtid = 811209465 and [desc] = 'FEHBP HCCLAIMPMT'

Open in new window


the error I get is An aggregate may not appear in the set list of an UPDATE statement.
Thanks in advance
SOLUTION
Avatar of Scott Pletcher
Scott Pletcher
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
update tblBNKrecon
set groupedpmtid = (select MAX(GroupedPmtID) + 1 from tblBNKrecon), newdesc = 'FEHBP'
where groupedpmtid = 811209465 and [desc] = 'FEHBP HCCLAIMPMT'
Avatar of damixa

ASKER

Thanks guys,
Im also getting a warning
Warning: Null value is eliminated by an aggregate or other SET operation.

everything seems to be working though. Can you tell me what this means?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of damixa

ASKER

Thanks a ton