nvarchar
nvarchar

Reputation: 69

SQL Server - Ignore inserts for a particular column

I have a bunch (in thousands against different tables) of auto generated INSERT statements. I want to ignore update to one particular column in the table.

For e.g.,

INSERT INTO TABLE1 (col1, col2, col3) VALUES (1, aced00057372002d, 'word')

I want to ignore any updates to col2. Is there a way to achieve this?

Thanks

Upvotes: 0

Views: 431

Answers (1)

Joe Stefanelli
Joe Stefanelli

Reputation: 135808

You'd need to code an INSTEAD OF trigger for each table to handle this.

CREATE TRIGGER tr_table1_no_col2 ON table1
INSTEAD OF INSERT
AS
    INSERT INTO table1
        (col1, col3)
        SELECT col1, col3
            FROM Inserted
GO

Upvotes: 3

Related Questions