本文介紹了比較 where 子句中的 uniqueidentifier的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問(wèn)題描述
限時(shí)送ChatGPT賬號(hào)..
我們有兩個(gè)表:MainTable
和 CloneOfMainTable
We have two tables : MainTable
and CloneOfMainTable
兩個(gè)表的結(jié)構(gòu)是:
ID : int Identity Primarykey
Foo: nvarchar(50)
RowVersion : uniqueidentifier
我們想通過(guò)比較 RowVersion 和 bla bla ... 來(lái)簡(jiǎn)單地獲取更新的行...
We want to simply get the updated rows by comparing RowVersion and bla bla ...
SELECT *
FROM MainTable
INNER JOIN CloneOfMainTable On MainTable.ID = CloneOfMainTable.ID
WHERE MainTable.RowVersion <> CloneOfMainTable.RowVersion
它不起作用^_^"
推薦答案
比較 uniqueidentifier 值沒(méi)有限制.由于該列可以為空,您可以使用 coalesce
來(lái)包含 null
值進(jìn)行比較:
There are no limitations on comparing uniqueidentifier values. As the column is nullable you may use coalesce
to include null
values in comparison:
WHERE coalesce(MainTable.RowVersion,'00000000-0000-0000-0000-000000000000') <> coalesce(CloneOfMainTable.RowVersion,'00000000-0000-0000-0000-000000000000')
這篇關(guān)于比較 where 子句中的 uniqueidentifier的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!