Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
SQL
SELECT @Principal= IIF(optionfieldvalue='',NULL,CAST(optionfieldvalue as decimal(38,18))) FROM @DATA WHERE TemplateFieldId = 47


this query was written in sql-server 2012. Now i want to change that to 2008 r2.

can any one help who to convert that code
Posted
Updated 23-Jul-15 2:09am
v2

1 solution

You can rewrite it using CASE WHEN as-
SQL
SELECT @Principal= CASE WHEN optionfieldvalue='' THEN NULL ELSE CAST(optionfieldvalue as decimal(38,18)) END FROM @DATA WHERE TemplateFieldId = 47


Hope, it helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900