Saturday, February 25, 2012

Alter Column datatype in SMO

I m trying to alter some columns' datatype in the existing database.

it seems in SMO, some datatype like Text, throw exceptions "Cos it's Text".

so how do I code it in SMO for this problem?

I read there are some TSQL solutions to create a temp table for this.

but can SMO has a way to impletment it?

best regards

Hi,

from which type to which type to you want to switch ? The common approach would be:

Server s = newServer(".");

Table t = s.Databases["Northwind"].Tables["SomeTable"];

t.Columns["ColA"].DataType = DataType.Int;

t.Alter();

HTH, Jens K. Suessmeyer.

-
http://www.sqlserver2005.de
-

|||

the problem I have is to alter Text Field to NText.

the exception is alter column x failed cos it's Text field.

all other datatypes seem straightforward.

if you have SMO solutions for this issue, I will be really appreciated.

thanks for the reply

|||

Did you ever find a solution for this? I ran into the same problem yesterday. I can convert nearly all datatypes, except text <> ntext.

I could understand it, if I was trying to convert from ntext to text, but thats not the scenario - it is text to ntext.

No comments:

Post a Comment