2017-06-14 62 views
0

與實體框架的應用和我的數據庫排序規則是:我如何使用分頁功能更新查詢

Latin1_General_CI_AS 

但我的客戶的數據庫是Georgian_Modern_Set_CI_AS。這對我們來說是一個很大的問題,但我們用「整理」功能解決了這個問題。我們用Latin1_General_CI_AS來比較nvarchar值,例如;

-- with this function we can easily select the data and get into our application. 
select Name collate Latin1_General_CI_AS as Name from Users 

但我有一些更新的聲明,我只是想問如何在更新查詢中使用'collat​​e'函數?

你有什麼想法嗎?

感謝

+0

你的WHERE子句中是什麼意思? – SqlWorldWide

+0

@SqlWorldWide它沒關係我的意思是有什麼辦法在更新查詢中使用collat​​e函數? – saulyasar

回答

1
The usual form is: 
update 
set 
from 
where x=y collate 'name of collation' 
0

有幾種方法可以更新過程中使用分頁功能。

here複製的一些代碼。

CREATE TABLE #temp1 (
     col1 NVARCHAR(10) COLLATE Latin1_General_CS_AS 
    , col2 NVARCHAR(30) COLLATE Latin1_General_CS_AS 
     ) 
GO 

CREATE TABLE #temp2 (
     col1 NVARCHAR(10) COLLATE Latin1_General_CI_AS 
    , col2 NVARCHAR(30) COLLATE Latin1_General_CI_AS 
     ) 
GO 

-- insert sample data 
INSERT INTO #temp1 (
     col1 
    , col2 
     ) 
SELECT 'test1', 'This is test row 1' 
UNION ALL 
SELECT 'test2', 'This is test row 2' 
UNION ALL 
SELECT 'test3', 'This is test row 3' 
GO 

INSERT INTO #temp2 (
     col1 
    , col2 
     ) 
SELECT 'test1', 'sample data item 1' 
UNION ALL 
SELECT 'test2', 'sample data item 2' 
UNION ALL 
SELECT 'test3', 'sample data item 3' 
GO 

UPDATE 
    t2 
SET 
    t2.col2 = t1.col2 
FROM 
    #temp1 t1 
INNER JOIN 
    #temp2 T2 
ON 
    t1.col1=t2.col1 COLLATE Latin1_General_CI_AS 

UPDATE 
    t2 
SET 
    t2.col2 = t1.col2 
FROM 
    #temp1 t1 
INNER JOIN 
    #temp2 T2 
ON 
    t1.col1=t2.col1 COLLATE DATABASE_DEFAULT 

UPDATE 
    t2 
SET 
    t2.col2 = t1.col2 
FROM 
    #temp1 t1 
INNER JOIN 
    #temp2 T2 
ON 
    t1.col1 COLLATE DATABASE_DEFAULT =t2.col1 

清理

-- clean up 
DROP TABLE #temp1 
GO 
DROP TABLE #temp2 
GO