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

*/

posted @ 2020-11-02 17:00  黑贝是条狗  阅读(916)  评论(0编辑  收藏  举报