Total Pageviews

2017/10/08

[Oracle to SQL Server Migration] NVL

Problem
In Oracle, NVL function lets you replace null (returned as a blank) with a string in the results of a query. 




If expr1 is null, then NVL returns expr2. If expr1 is not null, then NVL returns expr1.

The SQL statement is as follows:
SELECT DRAWING_ID,
       NVL(TARGET_INSFEE, 0)
FROM CAM_DRAWING

Owing to NVL is only for Oracle, but it cannot be executed in Microsoft SQL Server.


How-To
You can use ISNULL instead of NVL in Microsoft SQL Server.
The SQL statement is as bellows:
SELECT DRAWING_ID,
       ISNULL(TARGET_INSFEE, 0)
FROM CAM_DRAWING



No comments: