sqlserver 执行带参数的动态语句v
/*
--获取正式
declare @EcSql nvarchar(2000)
select @EcSql = ' insert into CuSaleCuId(CuId,OrdCuId,saler) select top 100 a.cuid,a.cuid,' + cast(@saler as varchar(10)) +
' from tn_bas_customer a where not exists(select 1 from CuSaleCuId b where b.saler = @saler and b.cuid = a.cuid )
' + @CuSql + ' order by a.cuid desc ' ;
exec sp_executesql @EcSql,N'@saler int output',@saler output
*/
好不容易活着