sql - Set value of the column to default for NULL values -
i have table column has default value 0. when null inserted table, want set default.
as insert query generic , used other databases too, cannot make changes insert statement.
can have constraints or case statement on create table, default 0 value inserted whenever null passed.
if can not change insert statement
have no way other creating instead of insert trigger
:
create trigger trtablename on schemaname.tablename instead of insert begin insert tablename (columna, columnb, ...) select isnull(columna, 0), isnull(columnb, 0), ... inserted end
Comments
Post a Comment