日期:2014-05-18 浏览次数:20546 次
--> 测试数据:[a1] if object_id('[a1]') is not null drop table [a1] create table [a1]([date] datetime,[txt_desc] varchar(100)) insert [a1] select '2012-03-09','up[have:+11],code:and,[case]' union all select '2012-03-10','up[have:+5],code:or,[then]' union all select '2012-03-11','down[have:+20],code:and,[then]' union all select '2012-03-12','up[have:+3],code:or,[or]' insert [a1] select top 1 [date],replace([txt_desc],left(substring([txt_desc]+' ', patindex( '%[0-9]% ',[txt_desc]+' '), len([txt_desc]+' ')),patindex( '%[^0-9]% ',substring([txt_desc]+' ', patindex( '%[0-9]% ',[txt_desc]+' '),len([txt_desc]+' ')))-1),'57') from a1 order by [date] desc select * from a1 /* date txt_desc 2012-03-09 00:00:00.000 up[have:+11],code:and,[case] 2012-03-10 00:00:00.000 up[have:+5],code:or,[then] 2012-03-11 00:00:00.000 down[have:+20],code:and,[then] 2012-03-12 00:00:00.000 up[have:+3],code:or,[or] 2012-03-12 00:00:00.000 up[have:+57],code:or,[or] */ 更正一下