[MSSQL] Incorrect code generated tor adding default value to existing column.
Database management in a single PHP file
Brought to you by:
jakubvrana
To add default value to column in MSSQL you have to use statement:
ALTER TABLE [Schema].[Table] ADD CONSTRAINT <name_of_default> DEFAULT "<defaul_value>" FOR [Column];
or you can omit "CONSTRAINT <name_of_default>" - than name of default will be generated automatically. </name_of_default>
Instead of that, Adminer is generating code:
ALTER TABLE [Table] ALTER COLUMN [Column] <type> DEFAULT '<defaul_value>';
There is also another problem. If you edit your table/column and you want to change two things at once - for instance you want to add default value and want to change column to be not nullable anymore, you getting one line of code :
ALTER TABLE [Table] ALTER COLUMN [Column] <type> <not/nullable> DEFAULT '<defaul_value>';
It can't work because one thing must be done by ALTER COLUMN, second must be done by ADD CONSTRAINT.
What else is important - any of these problems doesn't appear when you add columns. Adding columns works as it is.
Diff:
Fixed by 8456779e.