Description
Jira issue originally created by user @beberlei:
This issue is created automatically through a Github pull request on behalf of deeky666:
Url: #298
Message:
This PR fixes altering column default values. In SQL Server column default values are stored in constraints. CREATE TABLE
statements with column declarations like some_column NVARCHAR(50) NOT NULL DEFAULT 'default value'
internally creates a default constraint with an automatically generated name in the the system table sys.default_constraints
. ALTER TABLE
statements do not support the DEFAULT
clause in column alteration declarations, leading in SQL syntax errors. Thus changing a column's default value is currently not possible.
To alter a column's default value, the old column's default constraint hast to be dropped and recreated again. As a default constraint has to be referenced by name to be dropped, we need to create each default constraint with an own unique name. This PR generates separate statements for default constraint declarations. It generates a unique name consisting of the table name and the column name the default constraint is created for.
DF_TABLE_NAME_HASH%_%COLUMN_NAME_HASH%