0
我仍然得到錯誤代碼SQL服務器:無法解析排序規則衝突,儘管轉換
無法解析「Latin1_General_CI_AS」 並在等於操作規則「SQL_Latin1_General_CP1_CI_AS」之間的排序規則衝突。
儘管事實上我使用的轉換按照these兩個answers。這裏是我的代碼:
-- ...
from #TmpResult a
left join #GroupMemberTable b
on (a.DBO_Owner_Login COLLATE SQL_Latin1_General_CP1_CI_AS) = (b.login_name COLLATE SQL_Latin1_General_CP1_CI_AS)
我讓他們都轉換爲:SQL_Latin1_General_CP1_CI_AS
謝謝
UPDATE: 以下是完整的摘錄:
create table #TmpTableSec3 (database_name varchar(100), Database_Owner varchar(200), DBO_Owner_Login varchar(200), type varchar (100), privilege varchar(100), group_name varchar(500))
insert into #TmpTableSec3
select a.database_name, a.principal, a.DBO_Owner_Login, b.type, b.privilege, b.group_name
from #TmpResult a
left join #GroupMemberTable b
on (a.DBO_Owner_Login COLLATE SQL_Latin1_General_CP1_CI_AS) = (b.login_name COLLATE SQL_Latin1_General_CP1_CI_AS)
--a.DBO_Owner_Login = b.login_name
--fieldname COLLATE DATABASE_DEFAULT = otherfieldname COLLATE DATABASE_DEFAULT
where b.group_name is not null --and b.privilege = 'admin'
order by a.database_name
然後該表填充爲:
insert into #TmpResult
select a.database_name, a.Owner, b.DBO_Owner_Login from #TmpTableSec1 a
join #TmpTableSec2 b
on a.database_name = b.database_name
set @cmd = 'select name, suser_sname(owner_sid) from master.sys.databases where name = '''[email protected]+''''
--select @cmd
insert #TmpTableSec1 exec (@cmd)
--select @dbowner = (select suser_sname(owner_sid) from master.sys.databases where name = @name)
set @cmd = 'use '+ @name +'
select db_name(), name, suser_sname(sid)
from sys.database_principals where name = ''dbo'''
--select ''@DBO'' = (select suser_sname(sid) from sys.database_principals where name = ''dbo'') '
INSERT #TmpTableSec2 exec (@cmd)
問題可能是在''.....你的代碼的一部分 – Lamak
請張貼您嘗試執行 – NickyvV
@NickyvV我貼得更整個代碼,但我認爲這個問題是隻與該行相關 – LearnByReading