We help IT Professionals succeed at work.
Get Started

SQL string sensitive search

68 Views
Last Modified: 2016-01-04
declare @reason varchar(4000)

set @reason = 'Test, Reason'

select *
from Transactions t
where t.UserReason in (select item from dbo.CreateStringTable(@reason))

Open in new window


I have a stored procedure which accepts @reason as an incoming string parameter, but for the purposes of this post, I declred @reason manually, and assigned it some test values. In the stored procedure, we use a function "CreateStringTable", which accepts a string of comma separated values, and returns them as a column in a table.

To avoid confusion, the query above can be seen as:
select *
from Transactions t
where t.UserReason in (select columnA from TableA)

Open in new window



How do I do a case-sensitive search of this? In other words, if columnA only contains the word 'Test', and t.UserReason contains only the word 'test', no records should be returned.
Comment
Watch Question
Business Intelligence Developer and Analyst
CERTIFIED EXPERT
Top Expert 2015
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE