declare
MyTestCursor
cursor
for select applytime from xh_log
open MyTestCursor
declare @applytime varchar ( 50 )
fetch from MyTestCursor into @applytime
while @@FETCH_STATUS = 0
Begin
if ( substring ( @applytime , 6 , 2 ) = ' 一月 ' )
begin
update xh_log set applytime = replace (applytime, ' 一月 ' , ' -1- ' ) where substring (applytime, 2 ) = ' 一月 '
end
else if ( substring ( @applytime , 2 ) = ' 二月 ' )
begin
update xh_log set applytime = replace (applytime, ' 二月 ' , ' -2- ' ) where substring (applytime, 2 ) = ' 二月 '
end
else if ( substring ( @applytime , 2 ) = ' 三月 ' )
begin
update xh_log set applytime = replace (applytime, ' 三月 ' , ' -3- ' ) where substring (applytime, 2 ) = ' 三月 '
end
else if ( substring ( @applytime , 2 ) = ' 四月 ' )
begin
update xh_log set applytime = replace (applytime, ' 四月 ' , ' -4- ' ) where substring (applytime, 2 ) = ' 四月 '
end
else if ( substring ( @applytime , 2 ) = ' 五月 ' )
begin
update xh_log set applytime = replace (applytime, ' 五月 ' , ' -5- ' ) where substring (applytime, 2 ) = ' 五月 '
end
else if ( substring ( @applytime , 2 ) = ' 六月 ' )
begin
update xh_log set applytime = replace (applytime, ' 六月 ' , ' -6- ' ) where substring (applytime, 2 ) = ' 六月 '
end
else if ( substring ( @applytime , 2 ) = ' 七月 ' )
begin
update xh_log set applytime = replace (applytime, ' 七月 ' , ' -7- ' ) where substring (applytime, 2 ) = ' 七月 '
end
else if ( substring ( @applytime , 2 ) = ' 八月 ' )
begin
update xh_log set applytime = replace (applytime, ' 八月 ' , ' -8- ' ) where substring (applytime, 2 ) = ' 八月 '
end
else if ( substring ( @applytime , 2 ) = ' 九月 ' )
begin
update xh_log set applytime = replace (applytime, ' 九月 ' , ' -10- ' ) where substring (applytime, 2 ) = ' 九月 '
end
else if ( substring ( @applytime , 2 ) = ' 十月 ' )
begin
update xh_log set applytime = replace (applytime, ' 十月 ' , 2 ) = ' 十月 '
end
else if ( substring ( @applytime , 3 ) = ' 十一月 ' )
begin
update xh_log set applytime = replace (applytime, ' 十一月 ' , ' -11- ' ) where substring (applytime, 3 ) = ' 十一月 '
end
else if ( substring ( @applytime , 3 ) = ' 十二月 ' )
begin
update xh_log set applytime = replace (applytime, ' 十二月 ' , ' -12- ' ) where substring (applytime, 3 ) = ' 十二月 '
end
fetch next from MyTestCursor into @applytime
End
close MyTestCursor
deallocate MyTestCursor
for select applytime from xh_log
open MyTestCursor
declare @applytime varchar ( 50 )
fetch from MyTestCursor into @applytime
while @@FETCH_STATUS = 0
Begin
if ( substring ( @applytime , 6 , 2 ) = ' 一月 ' )
begin
update xh_log set applytime = replace (applytime, ' 一月 ' , ' -1- ' ) where substring (applytime, 2 ) = ' 一月 '
end
else if ( substring ( @applytime , 2 ) = ' 二月 ' )
begin
update xh_log set applytime = replace (applytime, ' 二月 ' , ' -2- ' ) where substring (applytime, 2 ) = ' 二月 '
end
else if ( substring ( @applytime , 2 ) = ' 三月 ' )
begin
update xh_log set applytime = replace (applytime, ' 三月 ' , ' -3- ' ) where substring (applytime, 2 ) = ' 三月 '
end
else if ( substring ( @applytime , 2 ) = ' 四月 ' )
begin
update xh_log set applytime = replace (applytime, ' 四月 ' , ' -4- ' ) where substring (applytime, 2 ) = ' 四月 '
end
else if ( substring ( @applytime , 2 ) = ' 五月 ' )
begin
update xh_log set applytime = replace (applytime, ' 五月 ' , ' -5- ' ) where substring (applytime, 2 ) = ' 五月 '
end
else if ( substring ( @applytime , 2 ) = ' 六月 ' )
begin
update xh_log set applytime = replace (applytime, ' 六月 ' , ' -6- ' ) where substring (applytime, 2 ) = ' 六月 '
end
else if ( substring ( @applytime , 2 ) = ' 七月 ' )
begin
update xh_log set applytime = replace (applytime, ' 七月 ' , ' -7- ' ) where substring (applytime, 2 ) = ' 七月 '
end
else if ( substring ( @applytime , 2 ) = ' 八月 ' )
begin
update xh_log set applytime = replace (applytime, ' 八月 ' , ' -8- ' ) where substring (applytime, 2 ) = ' 八月 '
end
else if ( substring ( @applytime , 2 ) = ' 九月 ' )
begin
update xh_log set applytime = replace (applytime, ' 九月 ' , ' -10- ' ) where substring (applytime, 2 ) = ' 九月 '
end
else if ( substring ( @applytime , 2 ) = ' 十月 ' )
begin
update xh_log set applytime = replace (applytime, ' 十月 ' , 2 ) = ' 十月 '
end
else if ( substring ( @applytime , 3 ) = ' 十一月 ' )
begin
update xh_log set applytime = replace (applytime, ' 十一月 ' , ' -11- ' ) where substring (applytime, 3 ) = ' 十一月 '
end
else if ( substring ( @applytime , 3 ) = ' 十二月 ' )
begin
update xh_log set applytime = replace (applytime, ' 十二月 ' , ' -12- ' ) where substring (applytime, 3 ) = ' 十二月 '
end
fetch next from MyTestCursor into @applytime
End
close MyTestCursor
deallocate MyTestCursor
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。