日期:2014-05-17 浏览次数:20491 次
create table tb_text (datetime1 varchar(50)) insert into tb_text (datetime1) select '2012-08-12,13:40:30' union all select '2012-08-12,13:41:30' union all select '2012-08-12,13:42:30' union all select '2012-08-12,13:43:30' union all select '2012-08-12,13:44:30' union all select '2012-08-12,13:45:30' union all select '2012-08-12,14:01:30' union all select '2012-08-12,14:02:30' union all select '2012-08-12,14:03:30' union all select '2012-08-12,14:04:30' union all select '2012-08-12,14:05:30' /* (所影响的行数为 11 行) */ select * from tb_text /* 2012-08-12,13:40:30 2012-08-12,13:41:30 2012-08-12,13:42:30 2012-08-12,13:43:30 2012-08-12,13:44:30 2012-08-12,13:45:30 2012-08-12,14:01:30 2012-08-12,14:02:30 2012-08-12,14:03:30 2012-08-12,14:04:30 2012-08-12,14:05:30 */ update tb_text set datetime1 = replace(datetime1,',',' ') /*(所影响的行数为 11 行)*/ select * from tb_text /* 2012-08-12 13:40:30 2012-08-12 13:41:30 2012-08-12 13:42:30 2012-08-12 13:43:30 2012-08-12 13:44:30 2012-08-12 13:45:30 2012-08-12 14:01:30 2012-08-12 14:02:30 2012-08-12 14:03:30 2012-08-12 14:04:30 2012-08-12 14:05:30 */ alter table tb_text alter column datetime1 datetime select * from tb_text /* 2012-08-12 13:40:30.000 2012-08-12 13:41:30.000 2012-08-12 13:42:30.000 2012-08-12 13:43:30.000 2012-08-12 13:44:30.000 2012-08-12 13:45:30.000 2012-08-12 14:01:30.000 2012-08-12 14:02:30.000 2012-08-12 14:03:30.000 2012-08-12 14:04:30.000 2012-08-12 14:05:30.000 */ select max(datetime1) from tb_text group by convert(char(13),datetime1,121) /* 2012-08-12 13:45:30.000 2012-08-12 14:05:30.000 */