2010-05-26 76 views
0

是否可以查詢SQL Server表中的時間戳(rowversion)列?如果是這樣,怎麼樣?時間戳列 - 是否可以查詢?

我想要做這樣的事情:

Select * From MyTable Where MyTimestampColumn = "???" 

但我不知道要放什麼東西在「???」

謝謝 - 蘭迪

+0

你能解釋一下你試圖解決什麼問題,而不是你如何解決它?你想寫什麼樣的查詢?它應該做什麼?你的數據是什麼?你期望輸出什麼? – 2010-05-26 16:52:03

+0

@Mark Byers - 這有點複雜,但可以說我只是想爲Timestamp列搜索特定的值。 – 2010-05-26 16:55:49

回答

3

timestamp數據類型相當於binary(8)。您可以查詢反對:

create table #t (somecolumn varchar(64), mytimestampcolumn timestamp) 

insert into #t (somecolumn) select 'hello world' 
insert into #t (somecolumn) select 'foo' 
select * from #t where mytimestampcolumn = 0x0000000000000978 -- this value will vary 

drop table #t 

注意時間戳已被棄用,在SQL Server 2008中在SQL Server(2005年,2000年)以前的版本,rowversiontimestamp的代名詞,以幫助未來的遷移。

0

是的。這實際上是binary(8)

爲什麼要使用它呢?它只是用來檢測UPDATE上的一行的其他更改。否則,您必須測試行中的所有列以進行更改。 MS訪問尤其是依賴於它的併發