change ntext data type to text, SQL Server

0

I need to change the data type of a field that is in "ntext" to "text". The reason is that I'm having trouble pulling the value from the database and generating a PDF with the DOMPDF component of php.

When trying to change command line:

ALTER TABLE MyTable ALTER COLUMN mycolumn text

I get the following error:

  

[Err] 42000 - [SQL Server] Can not change column 'mycolumn' to data type text

Is there any other way to change the data type of a table? Or force?

    
asked by anonymous 19.12.2017 / 17:13

1 answer

1

Try this:

ALTER TABLE mytable ADD mycolumn2 TEXT

UPDATE mytable SET mycolumn2 = mycolumn

ALTER TABLE mytable DROP column mycolumn 

ALTER TABLE mytable ADD mycolumn TEXT

UPDATE mytable SET mycolumn = mycolumn2

ALTER TABLE mytable DROP COLUMN mycolumn2
    
19.12.2017 / 18:06