本文介紹了比較 where 子句中的 uniqueidentifier的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
我們有兩個表:MainTable
和 CloneOfMainTable
We have two tables : MainTable
and CloneOfMainTable
兩個表的結構是:
ID : int Identity Primarykey
Foo: nvarchar(50)
RowVersion : uniqueidentifier
我們想通過比較 RowVersion 和 bla bla ... 來簡單地獲取更新的行...
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 值沒有限制.由于該列可以為空,您可以使用 coalesce
來包含 null
值進行比較:
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')
這篇關于比較 where 子句中的 uniqueidentifier的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!