0

So I've been using the query builder in visual studio (visual basic) to search a local mdb file. I have a button that is clicked to make a prompt for a search, and it works fine except that is is not case sensitive. Here is what I have so far:

SELECT ID, LastName, FirstName, FullTime, HireDate, Salary FROM SalesStaff WHERE LastName like ? + '%' 

My professor wants us to use the InStr fuction, but how do I get that to work with a prompt?

(InputBox in my vb form code). Furthermore, it doesn't seem to have case sensitivity either. This is the first time I am using SQL, so I hardly know what I'm doing.

Thanks in advance!

4
  • The default MS SQL installation is not case sensitive. Here is how to temporarily or permanently change it. blog.sqlauthority.com/2007/04/30/… Commented Nov 24, 2014 at 23:43
  • It told me ALTER TABLE is not supported... Commented Nov 25, 2014 at 0:52
  • ALTER TABLE is part of the core SQL standard....are you sure it didn't tell you that you don't have rights to the table? Commented Nov 25, 2014 at 1:52
  • I'd likely ask the professor why on earth he wants to use the InStr function? :) Commented Nov 25, 2014 at 7:48

1 Answer 1

1

You can amend the collation settings of your database/table. Alternatively if you just want a case sensitive comparison on this one statement you can use the collate keyword, such as below:

select 1 where 'abc' = 'ABC' select 1 where 'abc' collate Latin1_General_CS_AS = 'ABC' collate Latin1_General_CS_AS select 1 where 'abc' collate Latin1_General_CI_AS = 'ABC' collate Latin1_General_CI_AS select 1 where upper('abc') collate Latin1_General_CS_AS = 'ABC' collate Latin1_General_CS_AS select 1 where upper('abc') collate Latin1_General_CI_AS = 'ABC' collate Latin1_General_CI_AS 

CI stands for case insensitive.

CS stands for case sensitive.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.