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.
Author |
Topic |
snejsnej
Starting Member
9 Posts |
Posted - 2013-09-06 : 14:40:58
|
Hi,I have a number of columns I'm selecting from a table, and I'd like to use PATINDEX to search for a string within a field. Upon finding this string it would return another string...:SELECT CASE PARTNERID WHEN PATINDEX('%INX%',PARTNERID)>0 THEN 'AXXENT' ELSE PARTNERID END AS PARTNERID However, I'm getting this error:Incorrect syntax near '>'.Could someone please point me in the right direction?ThanksJens |
|
jethrow
Starting Member
37 Posts |
Posted - 2013-09-06 : 14:47:07
|
[code]SELECT CASE WHEN PATINDEX('%INX%',PARTNERID)>0 THEN 'AXXENT' ELSE PARTNERID END AS PARTNERID[/code]Microsoft SQL Server Noobie |
|
|
snejsnej
Starting Member
9 Posts |
Posted - 2013-09-06 : 15:03:00
|
quote: Originally posted by jethrow
SELECT CASE WHEN PATINDEX('%INX%',PARTNERID)>0 THEN 'AXXENT' ELSE PARTNERID END AS PARTNERID Microsoft SQL Server Noobie
Yup, that did it, thanks. I have other CASE statements where I include the name of the column right after 'CASE', and they work fine. If you have a minute, can you explain why it didn't work here?ThanksJens |
|
|
jethrow
Starting Member
37 Posts |
|
|
|
|