Can I change how TSQL evaluates values in SELECT statement?

  • Hello,

    I have older applicatio which has statement like this SELECT * FROM vare WHERE showOnWeb = TRUE

    Please note that TRUE value does not have quotes around it. Is there a swich I can change in SQL which will force it recognize those values as bool value of 1?

  • Not that I'm aware of. If I try to use code in that fashion it generates an error. You could substitute a local variable or hard code a value, but you're not going to be able to fundamentally alter the way the T-SQL language is interpreted. Sorry.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Grant Fritchey (5/20/2015)


    Not that I'm aware of. If I try to use code in that fashion it generates an error. You could substitute a local variable or hard code a value, but you're not going to be able to fundamentally alter the way the T-SQL language is interpreted. Sorry.

    Well this code worked in Access via ADO and it worked so I assumed there were some sort of compatibility setting which will allow SQL to ignore lack of quotes

  • artisticcheese (5/20/2015)


    Grant Fritchey (5/20/2015)


    Not that I'm aware of. If I try to use code in that fashion it generates an error. You could substitute a local variable or hard code a value, but you're not going to be able to fundamentally alter the way the T-SQL language is interpreted. Sorry.

    Well this code worked in Access via ADO and it worked so I assumed there were some sort of compatibility setting which will allow SQL to ignore lack of quotes

    Or, the Access code was changed into something else when it was sent to T-SQL through the linked server or whatever. In straight T-SQL, that generates an error. If you look at the reserve keywords, TRUE and FALSE are not. They're future reserve words and they're part of the ODBC set of words, not T-SQL. I think you're right, there was an interpretation, but I suspect it was from the Access end, not the SQL Server side of things. The functionality you're attempting to replication is for a boolean. SQL Server doesn't have a boolean data type. Again, sorry.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply