一个SQL语句可不行,估计得用游标遍历表中的各条记录,结合动态SQL执行吧。
解决方案 »
- SQL2000给邮箱字段自动赋值
- 初学者求delphi工资管理系统,包括完整的代码和SQL数据库.可运行
- 求一存储过程写法
- 我装sql2000时,出现一个问题,请帮我看一下
- sql server2005 表空间问题
- 菜鸟请教:SQL Server 的连接问题!
- 在线等!!windows server2003安装SQL2000企业版报错后ODBC驱动都没有了
- 每周统计问题,想要在周的字段后有日期,如:周一/11
- 弱弱的问题
- 谢谢你的指导,用DELPHI的EDIT框实现动态选择显示sql server数据库表的前几个记录
- 谁还记得那个关于SQL Server 对象命名的链接?(好像是邹建或是大力发起的帖)
- 求一个sql语句!比较难
用触发器不能实现吗?
非得用sql数据库解决公式计算的问题吗?
@prim1 real
@arithmetic varvhar(50)
)
return @r float
exec( 'select @r=@prim1'+replace(replace(@arithmetic,'×','*'),'÷','/'))
go仅适用于四则混合运算
其他运算还没测试
insert into Tb_UinonConfig select 100,'+20.5×15÷13.1'
insert into Tb_UinonConfig select 80 ,'÷2.5×100+23.0'
insert into Tb_UinonConfig select -80,'+100+(23.0×6)'
gocreate table #T(prim1 real,arithmetic varchar(50),value real)declare @prim1 real,@arithmetic varchar(50),@s nvarchar(4000)
declare t_cursor cursor for select * from Tb_UinonConfigopen t_cursorfetch next from t_cursor into @prim1,@arithmeticwhile @@fetch_status=0
begin
set @s=N'insert into #T select @prim1,@arithmetic,@prim1'+replace(replace(@arithmetic,'×','*'),'÷','/')
exec sp_executesql @s,N'@prim1 real,@arithmetic varchar(50)',@prim1,@arithmetic
fetch next from t_cursor into @prim1,@arithmetic
end
close t_cursor
deallocate t_cursorselect * from #T/*
prim1 arithmetic value
------- ----------------- -----------
100.0 +20.5×15÷13.1 123.47328
80.0 ÷2.5×100+23.0 3223.0
-80.0 +100+(23.0×6) 158.0
*/drop table #T,Tb_UinonConfig