22,210
社区成员
发帖
与我相关
我的任务
分享
create table #A
(
模号 char(10),
物料编号 varchar(20),
物料名称 varchar(20),
单位 char(10),
数量 int,
当前时间 nvarchar(50)
)
insert into #A values ('A','KH140347G3-153','KH140347G3-153','件',13,'2016年7月27日15时52分52秒')
insert into #A values ('A','KH140347G3-154','KH140347G3-154','件',14,'2016年7月28日15时52分52秒')
insert into #A values ('A','KH140347G3-155','KH140347G3-155','件',15,'2016年7月29日15时52分52秒')
insert into #A values ('B','KH140347G3-156','KH140347G3-156','件',16,'2016年7月2日15时52分52秒')
insert into #A values ('B','KH140347G3-157','KH140347G3-157','件',17,'2016年7月3日15时52分52秒')
insert into #A values ('B','KH140347G3-158','KH140347G3-158','件',18,'2016年7月8日15时52分52秒')
insert into #A values ('C','KH140348G5-101','KH140348G5-101','件',13,'2016年7月10日15时52分52秒')
insert into #A values ('C','KH140348G5-102','KH140348G5-102','件',14,'2016年7月13日15时52分52秒')
insert into #A values ('C','KH140348G6-201','KH140348G6-201','件',15,'2016年7月15日15时52分52秒')
insert into #A values ('D','KH140348G6-202','KH140348G6-202','件',16,'2016年7月17日15时52分52秒')
insert into #A values ('D','KH140348G6-203','KH140348G6-203','件',17,'2016年7月27日15时52分52秒')
insert into #A values ('D','KH140348G6-204','KH140348G6-204','件',18,'2016年7月30日15时52分52秒')
SELECT * from #A
select 模号,物料编号,物料名称,单位,数量,replace(replace(replace(replace(replace(replace(当前时间,'年','-'),'月','-'),'日',' ' ),'时','-'),'分','-'),'秒','') 当前时间 from #A
select max(当前时间) from #A
select 模号,物料编号,物料名称,单位,数量,
当前时间=cast(replace(replace(replace(replace(replace(replace(当前时间,'年','-'),'月','-'),'日',' ' ),'时',':'),'分',':'),'秒','') as datetime)
from #A