sexta-feira, 17 de abril de 2015

cannot alter column to be data type ntext

Today I was trying a simple script in a Sql Server Azure database, changing a column from text to ntext, when i got this message:

cannot alter column to be data type ntext

That was surprising. Googling the error, I found a stackoverflow thread about it, with a bunch of weird solutions. One of of them envolving creating a new columns as ntext, copying data to it, renaming and droping the older one... Ouch!

The best answer was a double stop move: changing the column to varchar(max) and finally to ntext (apparentely you can't change from text to ntext, but from other types to ntext it's ok... go figure...). 


ALTER TABLE mytable 
  ALTER COLUMN mycolumn VARCHAR(max) 

ALTER TABLE mytable 
  ALTER COLUMN mycolumn NTEXT 


Since it was a brand new colunmn, I didnt have to worry about possible data loss, but keep that in mind before you try this on your stack.

Bye!

--
Check out my new book about R Language http://www.amazon.com/dp/B00SX6WA06

Nenhum comentário:

Postar um comentário

Leave your comment here!