本文介绍了MS SQL DB中的归类更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello All,



我必须将DB排序规则更改为 Latin1_General_CI_AS(来自Latin1_General_CI_AI)。我的数据库有700多个表,每个表有40多个列,具有不同的数据类型。我的数据库大小为150 GB。



我尝试使用数据库进行更改 - >属性,但我有很多错误如下。



消息5075,16级,状态2,行3

统计'customergroupBase .ndx_Sync'依赖于数据库排序规则。如果架构绑定对象依赖于它,则无法更改数据库排序规则。删除对数据库排序规则的依赖关系,然后重试该操作。



因此,我计划使用以下步骤更改表中列的排序规则。



1.删除所有索引



2.使用下面的alter命令更改排序规则



ALTER TABLE TableName ALTER COLUMN [Name] nvarchar(160)COLLATE Latin1_General_CI_AS NULL



  3.重新创建所有索引。



我的问题是,b
$
1.这是整理更改,我需要更改表格中的所有字段(列)吗?或者只需要更改使用字符类型和文本类型的字段(列)?



2.更改排序规则后,当我在DB中创建新表或列时, DB会自动应用新的排序规则Latin1_General_CI_AS还是DB会使用旧排序规则 - Latin1_General_CI_AI?


解决方案

Hello All,

I have to change DB collation to Latin1_General_CI_AS (from Latin1_General_CI_AI). My DB having 700+ tables and each table is having 40+ columns with different data types. My DB size is 150 GB.

I have tried to change using Database--> properties, but i got lot of errors like below.

Msg 5075, Level 16, State 2, Line 3
The statistics 'customergroupBase.ndx_Sync' is dependent on database collation. The database collation cannot be changed if a schema-bound object depends on it. Remove the dependencies on the database collation and then retry the operation.

So, I have plan to change collation of columns in table with below steps.

1. Drop all indexes

2. Change collation using below alter command

ALTER TABLE TableName ALTER COLUMN [Name] nvarchar(160) COLLATE Latin1_General_CI_AS NULL

  3. Recreate all indexes.

My Question is,

1. it is a collation change, do i need to change all fields(columns) in table? or only need to change the fields(columns) that uses character types and text types?

2. After changing collation, when I create new table or columns in DB, will DB automatically apply new collation Latin1_General_CI_AS or will DB use old collation - Latin1_General_CI_AI?

解决方案


这篇关于MS SQL DB中的归类更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 09:13