sp_executesql得到执行sql语句的返回值

  执行 sql语句,得到 变量的值

 

declare @RangeKey int='20160901'
declare @Partition int;
DECLARE @SQLString nvarchar(500);  
DECLARE @ParmDefinition nvarchar(500);  

SET @SQLString = N'SELECT @RangeKeyOUT = $PARTITION.[pf_Fact_XM_XMBJXX] (20160925)';  
SET @ParmDefinition = N' @RangeKeyOUT int OUTPUT';  
  
EXECUTE sp_executesql @SQLString, @ParmDefinition, @RangeKeyOUT=@Partition OUTPUT;  
select @Partition

 

posted @ 2016-10-14 17:00  兴想事成  阅读(1099)  评论(0编辑  收藏  举报