•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 423,532 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,340 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 654 | Replies: 1
![]() |
•
•
Join Date: Feb 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hi Folks,
Just a quickie - can wildcards be used in CASE statements? I have inherited some code and wondered if this:
could be replaced with this:
Thanks
L3K
Just a quickie - can wildcards be used in CASE statements? I have inherited some code and wondered if this:
(case substring(anownedby,0,charindex('/',anownedby))
when '2361' then 'GOD' when '2361c' then 'GOD' when '2361d' then 'GOD'
when '6206252' then 'BIL' when 'bil' then 'BIL' else 'XXX' end) as branchcould be replaced with this:
(case substring(anownedby,0,charindex('/',anownedby))
when '2361%' then 'GOD' when '6206252' then 'BIL' when 'bil' then 'BIL' else 'XXX' end) as branchThanks
L3K
•
•
Join Date: Feb 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Just another thought, rather than taking a substring first, would something like the following be faster or will the 'like's hit performance worse:
Ta!
case
when anownedby like '2968%' then 'RUS'
when anownedby like '1997%' then 'LEW'
... 28 more 'whens'...
else 'XXX' end as branchTa!
Last edited by linker3000 : Feb 29th, 2008 at 10:06 am.
![]() |
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the MS SQL Forum
- Previous Thread: Convert Latin 1 (ISO-8859-1) to UTF-8
- Next Thread: Retrieving duplicate consecutive records.(How to make query for this scenario?)


Linear Mode