DL1
DL1

Reputation: 201

SSIS expression to SQL statement

I am trying to convert "Derived Columns" Expressions to SQL statements to be able to add and replace column values and names.

I am having some issues in finding the correct help to understand nested formulas in SSIS.

Formula i have in SSIS is,

[A] == 0 || ISNULL([A]) ? -1 :  [A]

How do i write this in a SQL statement?

Upvotes: 3

Views: 95

Answers (2)

Hadi
Hadi

Reputation: 37313

You can use the ISNULL() function

CASE ISNULL([A],0) WHEN 0 THEN -1 ELSE [A] END

Or

CASE WHEN [A] IS NULL THEN 0
           WHEN [A] = 0 THEN 0
           ELSE [A] END

Upvotes: 1

Jaydip Jadhav
Jaydip Jadhav

Reputation: 12309

Some thing like this

CASE WHEN [A] = 0 OR [A] IS NULL THEN -1  ELSE [A] END

Upvotes: 1

Related Questions