SQL Server整理2个数据库

时间:2017-07-25 10:42:10

标签: sql-server collation

我不得不采用现有的存储过程并对其进行修改,以便其中一个表现在来自不同的数据库。已经使用不同的整理序列建立了数据库。

到目前为止,这是我的代码:

ALTER PROCEDURE [dbo].[USP_GetContactDetails]            
    @SMID varchar(100) = ''            
AS                
BEGIN          
    SET NOCOUNT ON;    

    SELECT DISTINCT 
        a.StaffID as StaffID, a.FirstName as FirstName, 
        a.SurName as SurName, a.FirstName + ' ' + a.SurName as StaffName,        
        a.JobTitle as [Job Title],
        d.Dept as [Dept], a.Location as [Location], a.LocationID as [LocationID],
        ISNULL(b.Mobile, '') as [Mobile],        
        ISNULL(b.DirectFaxNo, '') as DirectFaxNo,    
        CAST(ISNULL(SP.[Profile_Description], '') AS VARCHAR(8000)) as [Profile],          
        DirectTel = ISNULL((SELECT TOP 1 siteTelephone 
                            FROM [Directory].dbo.Location o 
                            WHERE o.siteID = sit.SiteID), ''),
        OfficeFax = ISNULL((SELECT TOP 1 SiteFax 
                            FROM [Directory].dbo.Location o 
                            WHERE o.siteID = sit.SiteID), ''),
        ISNULL(a.EmailAddress,'') as Email,        
        C.Designation as Designation,  JobID = ' '         
INTO 
    #contacts 
FROM
    Contact_Details c 
LEFT JOIN
    [Directory].dbo.ExtraDetails b ON C.Staffid collate SQL_Latin1_General_CP1_CI_AS = b.Staffid,            
    (SELECT 
         s.locationid , s.StaffID,          
         dbo.FUN_GetOfficeID(s.LocationID) as officeid             
     FROM 
         [Directory].dbo.vwStaff s) as OfficeTable,          
    [Directory].dbo.vwStaff a         
LEFT OUTER JOIN
    [Directory].dbo.SiteLocation sit ON a.LocationID collate    SQL_Latin1_General_CP1_CI_AS = sit.LocationID         
LEFT OUTER JOIN
    dbo.Staff_Profile SP ON a.Staffid collate SQL_Latin1_General_CP1_CI_AS = SP.Staff_Id
LEFT OUTER JOIN
    [Directory].dbo.department d ON a.DeptID collate SQL_Latin1_General_CP1_CI_AS = d.DeptID
WHERE 
    OfficeTable.StaffID = a.StaffID            
    AND a.Staffid = c.Staffid               
    AND 

我一直收到以下错误,但我不知道还有什么需要整理声明。

  

Msg 468,Level 16,State 9,Line 1
  无法在等于操作的情况下解决“SQL_Latin1_General_CP1_CI_AS”和“Latin1_General_CI_AS”之间的排序规则冲突。

0 个答案:

没有答案