0

I have the following query, looking for salespeople of 'BG'.

SELECT *
  FROM [dbo].[JobOrders]
  where [salesperson] = 'BG'

When I use 'bg' instead, I do not get results. To my understanding 'BG' or 'bg' would bring back the same results.

Is there a setting that would prevent this?

3 Answers3

0

To avoid this situation you can always check using Upper cases

SELECT *
  FROM [dbo].[JobOrders]
  where upper([salesperson]) = 'BG'
KrazzyNefarious
  • 3,202
  • 3
  • 20
  • 32
0

Your salesperson column is almost certainly a foreign key and so would likely be populated by consistently cased values (ie they should be all upper case), so:

SELECT *
FROM [dbo].[JobOrders]
WHERE [salesperson] = UPPER('bg')

This would allow an index to still be used for the salesperson column.

Bohemian
  • 412,405
  • 93
  • 575
  • 722
0

You can make it case insensitive by using collation:

SELECT *
FROM [dbo].[JobOrders]
where [salesperson] = 'BG' COLLATE SQL_Latin1_General_CP1_CI_AS
Jayvee
  • 10,670
  • 3
  • 29
  • 40