begin
 drop table #tmptable
 declare @money ut_money
 set @money=1.2345
 create table #tmptable
 (
 je ut_money
 )
 
 insert into #tmptable(je) values(@money)
 
 select * from   #tmptable
 
 end

执行结果:

SQL中的动态语句执行--exec(@sqlstr)

第二段sql

1 begin
 2 drop table #tmptable
 3 declare @money ut_money
 4 set @money=1.2345
 5 create table #tmptable
 6 (
 7 je ut_money
 8 )
 9 
10 exec('insert into #tmptable(je) values('+@money+')')
11 
12 
13 select convert(varchar(20),@money)
14 select * from   #tmptable
15 
16 end

执行结果:

SQL中的动态语句执行--exec(@sqlstr)

以上结果表明:

exec(@sqlstr)

其中@sqlstr中如果包含变量的运算,是将变量转换为varchar后再exec操作