title: How to set a default value for a column in SQL Server when changing the column's data type?
body: <p>I want to change the data type of a column from integer to datetime in an SQL Server database.
  The column contains NULL values only.</p>
  <p>This works:
  <code>ALTER TABLE tablename ALTER COLUMN columnname DATETIME</code></p>
  <p>However this doesn't:
  <code>ALTER TABLE tablename ALTER COLUMN columnname DATETIME DEFAULT NULL</code></p>
  <p>I would like to know why exactly this doesn't work.</p>
  <p>I know that it is possible to add a default value with this command afterwards:</p>
  <p><code>ALTER TABLE tablename ADD CONSTRAINT DF_SomeName DEFAULT NULL FOR columnname</code></p>
  <p>But is there a way to change the data type and add a default value with just one command?</p>
  <p>EDIT: I have to do this in a Sybase db as well and there it works like this:
  <code>ALTER TABLE tablename MODIFY columnname DATETIME DEFAULT NULL</code></p>