日期:2014-05-17  浏览次数:20520 次

语句问题,,,
select @sql=' declare @accountid varchar(50) '                                              
select @sql=@sql+' select top 1 @accountid=accountid from '+@DTTable+' a with(nolock) '                      
select @sql=@sql+' left join v_faccount b with(nolock) on a.companyid=b.companyid and a.accountid=b.acctcode '                                              
select @sql=@sql+' where isnull(a.currency,'''')<>isnull(b.currency,'''') and a.doccode='''+@doccode+''' and                           
( left(a.accountid,4) in(''1001'',''1002''))'                                                         
select @sql=@sql+'  if isnull(@accountid,'''')<>'''''                                              
select @sql=@sql+'  begin raiserror(''科目:%s币种与科目设置不一致!'',16,1,@accountid) return end '                                                        
                                              
exec (@sql)
 

这样的语句,写成一条会不会快点,,怎么写成一条

------解决方案--------------------
写成这样主要是考虑扩充性,你确定是要写死?