Open GoogleCodeExporter opened 9 years ago
I think making it (getdate()) will also make that work. Can you give that a
shot?
Original comment by geoffl...@gmail.com
on 14 Feb 2009 at 8:26
Enclosing default value with parentheses does not solve the problem.
Here are convenient extension methods to deal with DEFAULT constraints.
public static class TransformationProviderExtensions
{
public static void AddDefaultConstraint(this ITransformationProvider provider, String name, String table, String column, String defaultValue)
{
provider["SqlServer"].ExecuteNonQuery(String.Format("ALTER TABLE {0} ADD CONSTRAINT {2} DEFAULT {3} FOR {1}", table, column, name, defaultValue));
}
public static void RemoveDefaultConstraint(this ITransformationProvider provider, String name, String table)
{
provider["SqlServer"].ExecuteNonQuery(String.Format("ALTER TABLE {0} DROP CONSTRAINT {1}", table, name));
}
}
Then one could use it this way:
Database.AddDefaultConstraint("ConstraintName", "TableName", "ColumnName", "(newid())");
Original comment by uksus70
on 31 May 2010 at 7:02
Original issue reported on code.google.com by
jyoung1...@gmail.com
on 13 Oct 2008 at 4:32