timestamp类型怎么比较

shen258cs 2010-07-09 04:07:33
lastmodify字段查出来的结果是这个0x00000000010A03C1

我要让这个字段进行比较,如何写?

在线等各位哥哥详解。。。。
...全文
651 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
shen258cs 2010-07-09
  • 打赏
  • 举报
回复
thank you 我去试试看
黄_瓜 2010-07-09
  • 打赏
  • 举报
回复
--> 测试数据:[tb]
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([id] int,[code] varchar(14),timestamp)
insert [tb]([id],[code])
select 1,'SLSD' union all
select 2,'SLSD' union all
select 3,'XTGS' union all
select 4,'WZBD'

select * from [tb] where timestamp>0x0000000000000FBF--不用加引号
/*
id code timestamp
----------- -------------- ------------------
4 WZBD 0x0000000000000FC0

(1 行受影响)
*/
SQL77 2010-07-09
  • 打赏
  • 举报
回复


不可为空的 timestamp 列在语义上等价于 binary(8) 列。可为空的 timestamp 列在语义上等价于 varbinary(8) 列。



BINARY比较
百年树人 2010-07-09
  • 打赏
  • 举报
回复
直接比较
select * from tb
/**
no gid value col
----- ----------- ----------- ------------------
00001 1 10 0x00000000000AB8F0
00002 2 11 0x00000000000AB8F1
00003 2 11 0x00000000000AB8F2
00004 3 9 0x00000000000AB8F3
00005 4 8 0x00000000000AB8F4
00006 4 10 0x00000000000AB8F5

(6 行受影响)
**/

select * from tb t
where not exists(select 1 from tb where gid=t.gid and col>t.col)
/**
no gid value col
----- ----------- ----------- ------------------
00001 1 10 0x00000000000AB8F0
00003 2 11 0x00000000000AB8F2
00004 3 9 0x00000000000AB8F3
00006 4 10 0x00000000000AB8F5

(4 行受影响)
**/
黄_瓜 2010-07-09
  • 打赏
  • 举报
回复
= > < !=
永生天地 2010-07-09
  • 打赏
  • 举报
回复
用= < >

34,873

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧