2014-10-10 150 views
0

請參閱下面的查詢:我在哪裏放置整理條款?

SELECT IDNUMBER collate SQL_Latin1_General_CP1_CI_AS  AS ciscrimeurn, 
     WID    AS nicheoccurrenceid, 
     OccurrenceFileNo AS nicheoccurrencefilno 
FROM [rmslive\sql2005].NicheRMS_Live.dbo.TBL_GOCCID 
     INNER JOIN [rmslive\sql2005].NicheRMS_Live.dbo.tbl_goccurrence 
       ON tbl_goccid.wid = tbl_goccurrence.id 
WHERE tbl_goccid.ID LIKE '2060609955%' 
UNION 
SELECT NULL    AS ciscrimeurn, 
     id    AS nicheoccurrenceid, 
     occurrencefileno AS nicheoccurrencefilno 
FROM [rmslive\sql2005].NicheRMS_Live.dbo.tbl_goccurrence 
WHERE id NOT LIKE '90309955%' 
EXCEPT 
SELECT CISIDNumber collate SQL_Latin1_General_CP1_CI_AS, 
     OccurrenceID, 
     OccurrenceFileNo 
FROM dbNicheCIS 

NicheRMS_Live和dbNicheCIS有不同的排序規則。兩者都是SQL服務器數據庫。

順時針是一個varchar,nicheoccurrenceid是一個小數,OccurrenceFileNo是一個整數。我不明白把整理條款放在哪裏。

+0

檢查了這一點 http://stackoverflow.com/questions/4405316/sql-server-2008-database-collat​​ion-conversion – 2014-10-10 11:49:06

+0

整理控制的順序排序字符串和字符。因此,在適用的列類型上使用它,在這種情況下,您的順時針字段。 – Kahn 2014-10-10 11:57:40

回答

0

如果你想更改列排序規則,然後

SELECT columnName COLLATE COLLATION_NAME 
FROM tableName 
+0

謝謝。我已經在包含你所說的內容的問題中修改了查詢,但我仍然收到錯誤。你可以看一下嗎? – w0051977 2014-10-10 12:59:08

+0

@ w0051977 OccurrenceID,OccurrenceFileNo – 2014-10-10 13:08:56