且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在不丢失数据的情况下更改SQL Server数据库中的列数据类型

更新时间:2023-02-03 08:37:25

检查此链接是否有一些建议。



SQL Server 2000 - 我该怎么做将列从文本更改为ntext? [ ^ ]


步骤:
Sql服务器 - 工具 - >选项 - >设计师 - >

在那里您可以找到未选中的自动生成更改脚本,因此请将其设置为检查。

取消选中
阻止保存需要重新创建表格的更改

保存 - >

现在打开表设计并将数据类型更改为文本到ntext并保存。

它会要求Overwrite然后选择Yes。


更改表TableName

更改列ColumnName YourDataType

I have SQL Server database and I just realized that I can change the type from one of the columns from text to ntext. How can I do that without losing the data that is already entered into that table?

PS. I am using SQL Server Server 2008.

Check this link for couple of advices.

SQL Server 2000 - How do I alter a column from text to ntext?[^]


Steps:
Sql server - Tools -> Options ->Designers ->

There You can find the Auto Generate Change Scripts which is unchecked,so make it as Check.

Uncheck the 
prevent saving Changes that requires Table re-Creation 

Save ->

Now open your table design and Change your datatype as text to ntext and Save it.

it will ask for Overwrite then go with Yes.


Alter Table TableName
Alter Column ColumnName YourDataType