0

Somehow this customer's database didn't update correctly, and now they have some number columns which should have a default value of 0 with no default value (but not null), and it creates an error that the column cannot be null when I try to do an insert.

I tried:

ALTER TABLE cesMisc ALTER COLUMN int1 int DEFAULT((0))

But it doesn't like the DEFAULT in the alter column. How can I define a default value to the column?

1 Answer 1

2

try:

create table xyz
(
column1 int not null
)

ALTER TABLE xyz ADD CONSTRAINT
    DF_column1 DEFAULT 0 FOR column1
GO
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.