question

Anil07 avatar image
Anil07 asked

Conversion failed error

Hi

I was wondering if someone could help. The following query is has error

select

case when [Time Taken for First ] >'24:00'

then

'>24' else 0 end as '1st assess',

*

from [dbo].['assessment ']

Msg 245, Level 16, State 1, Line 1

Conversion failed when converting the varchar value '>24' to data type int.

The column is nvarchar(255)

Please advise.

Anil

conversion
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
ThomasRushton avatar image
ThomasRushton answered

Try wrapping the 0 in quotes too.

I'm guessing, as you've not provided any sample data, that you have other rows that are returned first, and that calculation for those rows returns the zero value - which is a number - so the server is trying to build a column full of numbers, but then it comes across a value which is attempting to return a string, and can't do that...

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.