Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

alter column table and make default value to empty string

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

like image 935
Link Avatar asked Aug 10 '12 01:08

Link


2 Answers

You need to add a contraint. Referring to http://blog.sqlauthority.com/2008/05/31/sql-server-create-default-constraint-over-table-column/

ALTER TABLE Employee 
        ADD CONSTRAINT DF_Employee _JobTitle
        DEFAULT '' FOR sJobTitle 
like image 95
Jason Jong Avatar answered Nov 08 '22 13:11

Jason Jong


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

ALTER TABLE Employee
ADD DEFAULT ('') FOR sJobTitle 

maybe it work.

like image 29
Habib Zare Avatar answered Nov 08 '22 14:11

Habib Zare