alter-column

SQL Server - alter column - adding default constraint

I have a table and one of the columns is "Date" of type datetime. We decided to add a default constraint to that column Alter table TableName alter column dbo.TableName.Date default getutcdate() but this gives me Incorrect syntax near '.'. Does anyone see anything obviously wrong here, which I am missing (other than having a better...

SQL: ATER COLUMN to shorter CHAR(n) type

I'm working with MS SQL SERVER 2003. I want to change a column in one of my tables to have fewer characters in the entries. This is identical to this question: http://stackoverflow.com/questions/2281336/altering-a-table-column-to-accept-more-characters except for the fact that I want fewer characters instead of more. I have a column i...

SQL Server - Change a Nullable column to NOT NULL with Default Value

Hey everyone, I came across an old table today with a datetime column called 'Created' which allows nulls. Now, I'd want to change this so that it is NOT NULL, and also include a constraint to add in a default value (getdate()). So far I've got the following script, which works fine provided that i've cleaned up all the nulls beforeha...