22,209
社区成员
发帖
与我相关
我的任务
分享
if object_id('tempdb..#tb') is not null drop table #tb
create table #tb(expression nvarchar(max))
insert into #tb
select '1+1' union all
select '1+5-2*3' union all
select '(7.45-3.1)*(5-2)' union all
select 'power(2,6)' union all
select '2+3' union all
select 'ceiling(1234.8)'
declare @sql nvarchar(max)
select @Sql=
isnull(@sql+' union all ','')+N'select N'''+
expression+''' as [Expression],' +
expression + N' as [Result] ' from #tb
exec(@sql)
这方法也不太好select(7.45-3.1)*(5-2)