Msg 4145, Level 15, State 1, Line 7 An expression of non-boolean type specified in a context where a condition is expected, near ‘%.*ls’.


SQL Server Error Message:

An expression of non-boolean type specified in a context where a condition is expected, near ‘%.*ls’.

What and Why "this Error":

This error occurs when you try to use a non-boolean expression in the context where a boolean expression is expected. For example: the following statement will raise the above error.

USE tempdb
CREATE TABLE TEST
(
COL1 INT
)
GO
SELECT COL1 FROM TEST WHERE 1
GO
DROP TABLE TEST
GO

Msg 4145, Level 15, State 1, Line 7 An expression of non boolean type specified in a context where a condition is expected, near %.*ls. State 1 sql error4145 near %.*ls Msg 4145 Line 7 An expression of non boolean type specified in a context where a condition is expected Level 15 An expression of non boolean type specified in a context where a condition is expected

Action Required to resolve this Error:


The solution to this error is it must evaluate to a boolean result. In the above example we try to run a query that tries to use the non-boolean expression 1 in the WHERE clause. This raises the error. The following statement will execute successfully.

USE tempdb
CREATE TABLE TEST
(
COL1 INT
)
GO
SELECT COL1 FROM TEST WHERE COL1=1
GO
DROP TABLE TEST
GO



If this page has HELPED you somehow then do

You can also join me here to get daily SQL Server Tutorial / NEWS

Join me on TWITTER Join me on FACEBOOK Join me on LinkedINGet UPDATES via XML Feed Get Updates via Email

  • RSS
  • Newsletter
  • Facebook
  • Google+
  • LinkedIn
  • Twitter
  • YouTube