Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting incorrect sytax error with SQL Server

I have what I think should be a simple question but for the life of me cannot solve it myself. I'm just trying to do a simple search on a table.

Select *
From dbo.Case
Where dbo.Case.CountyName='Milwaukee'

I keep getting this error:

Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'Case'.

I've also tried taking off the "dbo" and it still does not work.

What am I doing wrong? (Using SQL Server 2008)

like image 333
user1946600 Avatar asked Apr 26 '26 21:04

user1946600


1 Answers

CASE is a reserved keyword. You will need to enclose it in [] to use as a an identifier such as a database, column, or table name:

Select *
From dbo.[Case]
Where dbo.[Case].CountyName='Milwaukee'
like image 139
Michael Berkowski Avatar answered Apr 28 '26 12:04

Michael Berkowski



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!