lastmodify字段查出来的结果是这个0x00000000010A03C1我要让这个字段进行比较,如何写?在线等各位哥哥详解。

解决方案 »

  1.   

    直接比较
    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 行受影响)
    **/
      

  2.   

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

  3.   

    --> 测试数据:[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 行受影响)
    */