7

Good day, just want to ask, is it possible to alter a column table and make the default value to empty string.

I tried using this query,

Alter Table Employee Alter Column sJobTitle Varchar(200) DEFAULT '' 

Unfortunately, it doesn't work..

Please let me know, if 'm doing it correct..

Thanks,

Link

4 Answers 4

9

You need to add a constraint.

Referring to SQL SERVER – Create Default Constraint Over Table Column

ALTER TABLE Employee 
  ADD CONSTRAINT DF_Employee _JobTitle
  DEFAULT '' FOR sJobTitle 
Sign up to request clarification or add additional context in comments.

Comments

6

try this query. this query does not change current datas to default.

ALTER TABLE Employee
ADD DEFAULT ('') FOR sJobTitle 

maybe it work.

Comments

2
ALTER TABLE Employee 
ADD sJobTitle varchar(200) NOT NULL DEFAULT ''

simplest answer.

Comments

0

You can try this, single and multiple column

Single column:

ALTER TABLE `DBname`.`table_name` 
 MODIFY COLUMN `foo_name` VARCHAR(255) NOT NULL DEFAULT '';

multiple column:

ALTER TABLE `DBname`.`table_name`
 MODIFY COLUMN `foo_name` VARCHAR(255) NOT NULL DEFAULT '',
 MODIFY COLUMN `foo_roll` VARCHAR(65) NOT NULL DEFAULT '';

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.