에서 SQL_Latin1_General_CP1_CI_AS
으로 AdventureWorks
데이터베이스의 데이터 정렬을 변경해야합니다. 아무도 그것을하는 방법을 알고 있습니까? SQL Server 2005에서 AdventureWorks 데이터베이스 데이터 정렬을 변경하는 방법?
alter database AdventureWorks set single_user
alter database AdventureWorks collate SQL_Latin1_General_CP1_CI_AS
alter database AdventureWorks set multi_user
을 그러나 나는 다음과 같은 오류 있어요 :
DECLARE @NewCollation VARCHAR(255), @DBName sysname
SELECT @NewCollation = 'SQL_Latin1_General_CP1_CI_AS', -- change this to the collation that you need
@DBName = DB_NAME()
DECLARE @CName varchar(255),
@TbleName sysname,
@objOwner sysname,
@Sql varchar(8000),
@Size int,
@Status tinyint,
@Colorder int
Declare CurWhileLoop cursor read_only forward_only local
for Select
QUOTENAME(C.Name)
,T.Name
,QUOTENAME(U.Name) + '.' +QUOTENAME(O.Name)
,C.Prec
,C.isnullable
,C.colorder
From syscolumns C
inner join systypes T on C.xtype=T.xtype
inner join sysobjects O on C.ID=O.ID
inner join sysusers u on O.uid = u.uid
where T.Name in ('varchar', 'char', 'text', 'nchar', 'nvarchar', 'ntext')
and O.xtype in ('U')
and C.collation != @NewCollation
and objectProperty(O.ID, 'ismsshipped')=0
order by 3, 1
open CurWhileLoop
SET XACT_ABORT ON
begin tran
fetch CurWhileLoop into @CName, @TbleName, @objOwner, @Size, @Status, @Colorder
while @@FETCH_STATUS =0
begin
set @Sql='ALTER TABLE '[email protected]+' ALTER COLUMN '[email protected]+' '[email protected]+ isnull ('('
+convert(varchar,@Size)+')', '') +' COLLATE '+ @NewCollation
+' '+case when @Status=1 then 'NULL' else 'NOT NULL' end
exec(@Sql) -- change this to print if you need only the script, not the action
fetch CurWhileLoop into @CName, @TbleName, @objOwner, @Size, @Status, @Colorder
end
close CurWhileLoop
deallocate CurWhileLoop
commit tran
그리고 오류 다음있어 : 같은 그런
Msg 5075, Level 16, State 1, Line 3
The object 'ufnLeadingZeros' 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.Msg 5075, Level 16, State 1, Line 3
The object 'CK_ProductReview_Rating' 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.Msg 5075, Level 16, State 1, Line 3
The object 'CK_TransactionHistory_TransactionType' 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.Msg 5075, Level 16, State 1, Line 3
The object 'CK_ProductVendor_AverageLeadTime' 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.
내가하려고했던 무언가를
Msg 4104, Level 16, State 1, Line 10
The multi-part identifier "U.Name" could not be bound.
AdventureWorks
데이터베이스에 대해이 마지막 쿼리를 실행하려고했는데 위와 같이 U.Name 이름 오류가 발생했으며 master 데이터베이스에 대해이 쿼리를 실행할 때 아무 일도 발생하지 않았습니다.
도와주세요!
AdventureWorks와 스크립트에서 오류가 발생하는 이유는 대/소문자를 구분하여 'U'와 'u'가 동일하지 않기 때문입니다. 이러한 문제를 해결하고 다시 시도하면 어떻게됩니까? 마스터의 데이터 정렬을 변경하는 유일한 방법은 데이터를 다시 작성하는 것입니다. –
이 U 문제를 해결할 때 다음과 같이 나타납니다. 메시지 102, 수준 15, 상태 1, 줄 1 '근처에 구문이 잘못되었습니다. :( – truthseeker
) @Size = -1 일 때'convert (varchar, @ Size)'는 'else'로 변환해야합니다. DB가 아닌 열. 문제가되는 제약 조건 등을 제거하고 ** 데이터베이스 ** 데이터 정렬을 변경하고 다시 추가해야합니다. –