Tuesday, March 27, 2012

Adding a new VarBinaryMax column to an existing table using SMO.

Consider the following code.

Table applicationSettingsTable = database.Tables["application_settings"];

Column logoColumn = new Column(applicationSettingsTable, "logo", DataType.VarBinaryMax);

applicationSettingsTable.Columns.Add(logoColumn);

applicationSettingsTable.Alter();

I don't understand why - but when I execute this code I end up with a column that has the data type varbinary(1) in the database rather than varbinary(MAX). I can't see anything in the msdn documentation that tells me I need to do something special for varbinary(max) columns, but maybe I do?

Any help much appreciated.

This appears to work tho...

Column logoColumn = new Column(applicationSettingsTable, "logo", DataType.VarBinary(-1));

No comments:

Post a Comment