[tt][blue]
Case When CONVERT(int, age) < 18
Then CONVERT(Bit, 1)
Else CONVERT(Bit, 0)
End AS IsJuvenile
[/blue][/tt]
You don't need the additional check for empty string because SQL Server converts an empty string to 0.
See...
Select Convert(int, '')
You will need to be a little careful about strings that can't be converted to int, like....
Select Convert(int, 'Older than dirt.')
[red][tt]Syntax error converting the varchar value 'Old enough to know better' to a column of data type int.[/tt][/red]
-George
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.