I need to change my column datatype from nText null
to nvarchar(1026) null
.
I have used the below query(Sql server).
ALTER TABLE [Tablename] ALTER COLUMN [Columnname] nvarchar(1026) null
while executing the query, I am getting the following issue:
Cannot alter column of type NTEXT or IMAGE [ Column Name = Columnname]
Any help would be appreciated ! Thanks in advance :)
答案 0 :(得分:3)
Your SQL statement is working fine in Sql Server 2014.
I believe you have to perform several steps.
Create a new column in your table
ALTER TABLE [Tablename] ADD [NewCol] nvarchar(1026) null
Copy original column content to the new column using UPDATE
and CONVERT
UPDATE [Tablename] SET NewCol=CONVERT(nvarchar(1026), Columnname)
Drop original column
ALTER TABLE [Tablename] drop column [Columnname]
Rename new column back to the original name
Exec sp_rename 'Tablename.NewCol', 'Columnname', 'Column'