select case when isnull('sdas',0)=0 then 'hi' else 'bye' end as 'Value'

The below query

select case when isnull('23',0)=0 then 'hi' else 'bye' end as 'Value'

returns bye

  • Unique key vs. unique index on SQL Server 2008
  • SQL placeholders in WHERE clause
  • Design database based on EAV or XML for objects with variable features in SQL Server?
  • SQL Query error help to solve
  • Rolling Mathematics in SQL (TSQL)
  • How do I unit test persistence?
  • BUT

    select case when isnull('sdas',0)=0 then 'hi' else 'bye' end as 'Value'
    

    returns the following Error message in MS-SqlServer2008R2

    Msg 245, Level 16, State 1, Line 1
    Conversion failed when converting the varchar value 'sdas' to data type int.
    

    Can you clarify it on which stage it gets conversion has been done

    2 Solutions collect form web for “select case when isnull('sdas',0)=0 then 'hi' else 'bye' end as 'Value'”

    '23' can be converted to int on the fly, but 'sdas' don’t.
    take string(varchar)-type for all variables:

    select case when isnull('sdas','0')='0' then 'hi' else 'bye' end as 'Value'
    

    The problem is converting sdas to an integer 0. Instead of using the isnull function, you could use the is null operator:

    select case when 'sdas' is null then 'hi' else 'bye' end as 'Value' 
    
    MS SQL Server is a Microsoft SQL Database product, include sql server standard, sql server management studio, sql server express and so on.