Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I always have to run multiple queries to update things because I don't know how to nest if/then in an update in Access SQL. There has got to be some way to combine these to do one update:UPDATE CovElig AS celSET cel.GrpNmeCd = 001WHERE (Mid([cel].[GrpName],10,1)="S"));UPDATE CovElig AS celSET cel.GrpNmeCd = 006WHERE (Mid([cel].[GrpName],10,1)="B"));UPDATE CovElig AS celSET cel.GrpNmeCd = 910WHERE (Mid([cel].[GrpName],10,1)=""));
robvolk
Most Valuable Yak
15732 Posts
Posted - 2011-08-31 : 16:55:30
This should work as a single UPDATE:
UPDATE CovElig SET CovElig.GrpNmeCd = Switch(Mid([GrpName],10,1)="S","001", Mid([GrpName],10,1)="B","006", Mid([GrpName],10,1)="","910")WHERE Mid([GrpName],10,1) In ("S","B","");