哪位大神知道此女名字有个符号!!!谢谢了 给高分

请问一存储过程 字符拆分的有关问题 最好不要用函数 送高分! 多谢 - Sql Server当前位置:& &&&请问一存储过程 字符拆分的有关问题 最好不要用函数请问一存储过程 字符拆分的有关问题 最好不要用函数 送高分! 多谢&&网友分享于:&&浏览:11次请教一存储过程 字符拆分的问题 最好不要用函数 送高分! 谢谢@express & 为计算表达式中的数据 &
数据类型如下 & A+B+C-E-F*D/F.....之类的数据 & 请问该如何取出各种符号中间的数据 & 谢谢
CREATE & PROCEDURE & dt_guestroom_income & (@p1 & char(2) & output,@p2 & datetime)
declare & @line_y & char(3) & --列号
declare & @subj_name & varchar(64)--科目名称
declare & @today_income & numeric & --当天收入
declare & @lastyear_today_income & numeric & --去年同日
declare & @month_income & numeric & --本月收入
declare & @year_income & numeric &
& --本年收入
declare & @last_time & numeric & --去年同期
declare & @growth_rate & numeric & --增长率
declare & @express & char(128) & --计算表达式
declare & @check &
& char(1) & --符号表达式
declare & @i & int--位置记数
--declare & @pos & int & --符号位置
declare & @subj_code & varchar(16)
--从科目基础表中查出相应的科目行号,科目名称
delete & from & ht_test_table1
--从表ht_check_report_design中取科目名称和计算表达式
Declare & Cur_tmp &
& Cursor & For
select & subj_name,express
from & ht_check_report_design
where & code &
open & Cur_tmp &
& Next & From & Cur_tmp & into & @subj_name,@express
WHILE & @@FETCH_STATUS & = & 0
FETCH & NEXT & FROM & Cur_tmp & into & @subj_name,@express
+,-,*,/,h & 等符号
--若为+号则
if & ( & CHARINDEX( '+ ', & @express,1)& 0)
----做加法处理 & 发现+号 & 拆分前面和后面的数据
& SET & @i=1
WHILE & @i &=LEN(@express) &
& if & ( & SUBSTRING & (@express,@i,1) & = &
'+ ')
& 取出加号和前一个符号前的代码 &
& SET & @+1
--若为-号则
if(CHARINDEX( '- ',@express,1)& 0)
---做减法处理
--若为*号则
if(CHARINDEX( '* ',@express,1)& 0)
---做乘法处理
--若为/号则
if(CHARINDEX( '/ ',@express,1)& 0)
---做除法处理
if(CHARINDEX( 'h ',@express,1)& 0)
& print & @subj_name & + '-- '
--做h的处理
CLOSE & Cur_tmp
Deallocate & Cur_tmp
--从科目汇总表ht_cash_subj_rep中按科目代码取出符合条件数据
GO ------解决方案--------------------declare @str varchar(100), @sql varchar(8000)
set @str= 'A+B+C-E-F*D/F '
select @sql= 'select
' ' '
select @+replace(replace(replace(replace(@str,
'/ ',
' ' ' union all select
' ' '),
'* ',
' ' ' union all select
' ' '),
'- ',
' ' ' union all select
' ' '),
'+ ',
' ' ' union all select
' ' ')+ ' ' ' '
--print @sql
exec(@sql)
12345678910
12345678910
12345678910 上一篇:下一篇:文章评论相关解决方案 12345678910 Copyright & &&版权所有

我要回帖

更多关于 哪位大神有看片的网站 的文章

 

随机推荐