OiO.lk Blog SQL Using IIF in SQL update statement – Returns [S0001][207] Invalid column name
SQL

Using IIF in SQL update statement – Returns [S0001][207] Invalid column name


I am using IIF in an Update query to set a column in SQL Server table, however I am getting an error "Invalid column name ‘Y’"

Here is the query, I want to update a column called PREVIOUS_STATUS to ‘Y’ only if another column DATE_CREATED is not null

UPDATE [dbo].[ACCOUNT]
    SET STATUS            = 'ACTIVE'
        PREVIOUS_STATUS   = IIF(DATE_CREATED IS NULL, PREVIOUS_STATUS, 'Y')
    WHERE [dbo].[ACCOUNT].ACCOUNT_NUMBER = 100;



You need to sign in to view this answers

Exit mobile version