0

I have a table abc in mssql which has column xyz which has its default has been set to not null, so the insert query fails when it has null value, I need help to change the default so that it accepts null values, table has only one constraint and its not on the column that I want to modify .

jh314
  • 27,144
  • 16
  • 62
  • 82
Dr.Grey
  • 1
  • 2

2 Answers2

0
ALTER TABLE xyz
ALTER COLUMN xyz NVARCHAR(10) NULL

Alter should work fine here, obviously change NVARCHAR(10) to whatever type you need

Ross
  • 112
  • 1
  • 17
0

According to (How to set a default value for an existing column)

You have 2 options: 1. Setting a constraint: ALTER TABLE Employee ADD CONSTRAINT DF_SomeName DEFAULT N'SANDNES' FOR CityBorn;

  1. Add Default: ALTER TABLE Employee ADD DEFAULT 'SANDNES' FOR CityBorn
Community
  • 1
  • 1