594
社区成员
发帖
与我相关
我的任务
分享
不懂,帮顶,学习,蹭分.
--> 测试数据: #tb
if object_id('tempdb.dbo.#tb') is not null drop table #tb
go
create table #tb (id varchar(1),a timestamp)
insert into #tb (id)
select '1' union all
select 'a'
/*
select *,dt=cast(a as datetime) from #tb
id a dt
---- ------------------ ----------------------------
1 0x00000000000007F3 1900-01-01 00:00:06.783
a 0x00000000000007F4 1900-01-01 00:00:06.787
(2 行受影响)
*/
create table ##(id varchar(1),b datetime)
insert ## select top 1 * from #tb order by a desc
select * from ##
/*
id b
---- -----------------------
a 1900-01-01 00:00:06.787
(1 行受影响)
*/