您好我已经创建了以下脚本,我遇到的问题是我正在查询的两个表的排序方式不同,我试图将数据插入到第三个表中,但是由于表的排序,我不能这样做,由于数据库和依赖它的程序的限制,我也无法自行整理表格。那么是否可以正确整理呢?
Error: Msg 468, Level 16, State 9, Line 69
Cannot resolve the collation conflict between "SQL_Latin1_General_CP1_CI_AS" and "Latin1_General_CI_AS" in the equal to operation.
--Create Table #tmp2(FK_clientids varchar(50))
--Create table #tmp (phonenums varchar(50))
--Create table #tmp3 (phonenum varchar(50),fk_applicationid_solref varchar(50),calldata varchar(50),sourcetable varchar(50))
Delete from #tmp2
Delete from #tmp
Use DATABASE2
INSERT INTO #tmp2
SELECT fk_clientid
FROM DM_ClientApplicants
where FK_ApplicationID in (39591,
39594,
39598,
39596,
39600,
39601,
39603,
39609,
39613,
39585,
39560)
Use DATABASE2
INSERT INTO #tmp
Select phonenum2 from DM_PhoneNumbers
where FK_ApplicationID in
(
Select FK_clientIDs from #tmp2
)
INSERT INTO #tmp
Select PhoneNum1 from DM_PhoneNumbers
where FK_ApplicationID in
(
Select FK_clientIDs from #tmp2
)
INSERT INTO #tmp
Select PhoneNum2 from DM_PhoneNumbers
where FK_ApplicationID in
(
Select FK_clientIDs from #tmp2
)
INSERT INTO #tmp
Select PhoneNum3 from DM_PhoneNumbers
where FK_ApplicationID in
(
Select FK_clientIDs from #tmp2
)
INSERT INTO #tmp
Select Partnerphonehome from DM_PhoneNumbers
where FK_ApplicationID in
(
Select FK_clientIDs from #tmp2
)
INSERT INTO #tmp
Select Partnerphonemobile from DM_PhoneNumbers
where FK_ApplicationID in
(
Select FK_clientIDs from #tmp2
)
INSERT INTO #tmp
Select Partnerphonework from DM_PhoneNumbers
where FK_ApplicationID in
(
Select FK_clientIDs from #tmp2
)
Use DATABASE1
insert into #tmp3
Select sourcetable,CallData,PhoneNum,P.FK_ApplicationID from Dial D
join DATABASE2.dbo.DM_PhoneNumbers P on PhoneNum = PhoneNum1
join DATABASE2.dbo.DM_Sol s on S.FK_ApplicationID = P.FK_ApplicationID
Collate Latin_general_CI_AS
where PhoneNum in
(
Select phonenums from #tmp
)