indikad
asked on
SQL question replacing case statement TSQL SQL server 2000
Appreciate if someone can do a quick QA on this code and let me know if I am on the right track.
the SQL belongs to a stored procedue of a large Web system. I do not have the development enviorenment for the entire system, but need a change to one of the stored prcedures so its kind of very hard to do full testing.
the existing code extracts a hard coded string (DCode) depending on the Descr in the ClassMaster table. But new requirements are DCode can change. So we built a new table with a link to ClassMaster ( DGCodes ). The new table cotains the DCode that the user can edit.
I just want to make sure the new SQL code does teh same job as before.
here is the table structure
here is the Existing code
here is the new code
the SQL belongs to a stored procedue of a large Web system. I do not have the development enviorenment for the entire system, but need a change to one of the stored prcedures so its kind of very hard to do full testing.
the existing code extracts a hard coded string (DCode) depending on the Descr in the ClassMaster table. But new requirements are DCode can change. So we built a new table with a link to ClassMaster ( DGCodes ). The new table cotains the DCode that the user can edit.
I just want to make sure the new SQL code does teh same job as before.
here is the table structure
DGCodes table
ClassId Descr DCode
000000001G00000001YN A 1
0000000033000000001M B 2
00000000880000000014 C 3
ClassMaster table
ClassId Descr
000000001G00000001YN A
0000000033000000001M B
00000000880000000014 C
here is the Existing code
Select
case c.Descr
When 'A' then '1'
When 'B' then '2'
When 'C' then '3'
else ''
end as DCode
from ClassMaster c join PartMain im on c.ClassId = im.ClassId
here is the new code
Select DGCodes.DCode
from DGCodes join join PartMain im on im.ClassId = DGCodes.ClassId
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
ASKER
yes the "join" - it was a typo when placing the edited code in here.