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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -