troubleshooting Question

SQL question replacing case statement TSQL SQL server 2000

Avatar of indikad
indikad asked on
Microsoft SQL Server
3 Comments1 Solution324 ViewsLast Modified:
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
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
Pratima Pharande

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros