SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 CASE vs TABLE RELATION MAPPING
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

milo.cabs
Starting Member

1 Posts

Posted - 05/11/2012 :  02:47:07  Show Profile  Reply with Quote
Hi.. wanted to know if what performs better in terms of execution time..
a CASE WHEN 1 THEN "<STRING>" WHEN 2 THEN "<STRING>" or just creating another table with CODE and DESC and map it on query.. thanks

tkizer
Almighty SQL Goddess

USA
35007 Posts

Posted - 05/11/2012 :  02:50:05  Show Profile  Visit tkizer's Homepage  Reply with Quote
I don't see how those can even be compared. Could you show us a data example?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Lamprey
Flowing Fount of Yak Knowledge

3829 Posts

Posted - 05/11/2012 :  15:21:06  Show Profile  Reply with Quote
You should try both see what happens. There is a good chance that just using a CASE expresson is going to perform faster than using a "lookup" domain table. But, I doubt it'll be much of a difference. Additionally, if you are going to do this "translation" on any sort of regular basis, a domain table is the correct answer.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47069 Posts

Posted - 05/11/2012 :  15:39:39  Show Profile  Reply with Quote
It depends on scenario. If its an adhoc one time mapping i would go for a CASE statement but if its a natural ID description mapping and its frequently used I would go for a mapping table which enables us to modify (add/remove/change) values based on our requirement and doesnt need to tweak CASE WHEN for each change of value pair

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000