Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
I need to see whether a particular word is there in a string or not.Like @Roles = 'Admin,Customer'I need to check whether 'Admin' word is there in @Roles. How can I do this?Thanks,
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2012-02-22 : 12:25:09
You can use the like construct:
SELECT CASE WHEN ','+@roles+',' LIKE '%,Admin,%' THEN 'Yes' ELSE 'No' END;