I came across an old table today with a datetime column called \'Created\' which allows nulls. Now, I\'d want to change this so that it is NOT NULL, and also include a constrai
you need to execute two queries:
One - to add the default value to the column required
ALTER TABLE 'Table_Name` ADD DEFAULT 'value' FOR 'Column_Name'
i want add default value to Column IsDeleted as below:
Example: ALTER TABLE [dbo].[Employees] ADD Default 0 for IsDeleted
Two - to alter the column value nullable to not null
ALTER TABLE 'table_name' ALTER COLUMN 'column_name' 'data_type' NOT NULL
i want to make the column IsDeleted as not null
ALTER TABLE [dbo].[Employees] Alter Column IsDeleted BIT NOT NULL