MS-SQL Error on removing a column using SMO

Asked By 0 points N/A Posted on -
qa-featured

Hi guys,

I am trying to figure out why I can add a column to a table using SMO, but when I try and remove a column, I get an error which indicates the following:

You cannot perform operation Remove on an object in state Existing. (Microsoft.SqlServer.Smo)

That makes no sense. Surely when you remove a column, the state is Existing.

The code used to add and remove is as follows:

myTable.Columns.Add(myColumn)

myTable.Columns.Remove(myColumn)

I did a little searching on this but could not get any solution. Does anybody have some clues?

Waiting for reply.

SHARE