Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
DO CASE equavalent in Transact-SQL
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2005
Miscellaneous
Thread ID:
01326640
Message ID:
01326647
Views:
16
This message has been marked as the solution to the initial question of the thread.
>Hi everybody,
>
>Is there a DO CASE equavalent in Transact-SQL for procedural code, e.g.
>
>CASE @PersonType = ' '
>   One select statement
>case ...
>   Different select statement
>
>etc.
>
>Thanks in advance.
>
>Creating different strings and using sp_executesql doesn't sound like a good approach to me. I'm guessing I need to use IF statements since there seems to be no CASE alternative for procedural code in T-SQL.

No. T-SQL CASE is used in a select statement to conditionally evaluate field results.

IF..ELSE is ugly but it does work.
____________________________________

Don't Tread on Me

Overthrow the federal government NOW!
____________________________________
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform