执行 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