You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SELECT DISTINCT QUOTENAME(c.name) AS column_name, c.column_id
2882
+
SELECT DISTINCT QUOTENAME(c.name) AS column_name, QUOTENAME(c.name,'''''''') AS ColumnNameWithApostrophes, c.column_id
2882
2883
FROM '+QUOTENAME(@DatabaseName) + N'.sys.partitions p
2883
2884
INNER JOIN '+QUOTENAME(@DatabaseName) + N'.sys.columns c ON p.object_id = c.object_id
2884
2885
INNER JOIN '+QUOTENAME(@DatabaseName) + N'.sys.index_columns ic on ic.column_id = c.column_id and ic.object_id = c.object_id AND ic.index_id = p.index_id
@@ -2887,9 +2888,10 @@ BEGIN
2887
2888
AND EXISTS (SELECT * FROM '+QUOTENAME(@DatabaseName) + N'.sys.column_store_segments seg WHERE p.partition_id = seg.partition_id AND seg.column_id = ic.index_column_id)
SELECT @ColumnList AS ColumnstoreColumnList, @PartitionCount AS PartitionCount, @ShowPartitionRanges AS ShowPartitionRanges;
2918
+
SELECT @ColumnList AS ColumnstoreColumnList, @ColumnListWithApostrophes AS ColumnstoreColumnListWithApostrophes, @PartitionCount AS PartitionCount, @ShowPartitionRanges AS ShowPartitionRanges;
2917
2919
2918
2920
IF @ColumnList <>''
2919
2921
BEGIN
2920
2922
/* Remove the trailing comma */
2921
2923
SET @ColumnList =LEFT(@ColumnList, LEN(@ColumnList) -1);
2924
+
SET @ColumnListWithApostrophes =LEFT(@ColumnListWithApostrophes, LEN(@ColumnListWithApostrophes) -1);
2922
2925
2923
2926
SET @dsql =N'USE '+QUOTENAME(@DatabaseName) + N';
2924
2927
SELECT partition_number, '
@@ -2960,7 +2963,8 @@ BEGIN
2960
2963
LEFT OUTER JOIN '+QUOTENAME(@DatabaseName) + N'.sys.partition_range_values prvs ON prvs.function_id = pf.function_id AND prvs.boundary_id = p.partition_number - 1
2961
2964
LEFT OUTER JOIN '+QUOTENAME(@DatabaseName) +N'.sys.partition_range_values prve ON prve.function_id = pf.function_id AND prve.boundary_id = p.partition_number 'ELSEN' 'END
2962
2965
+N' LEFT OUTER JOIN '+QUOTENAME(@DatabaseName) + N'.sys.column_store_segments seg ON p.partition_id = seg.partition_id AND ic.index_column_id = seg.column_id AND rg.row_group_id = seg.segment_id
2963
-
WHERE rg.object_id = @ObjectID'
2966
+
WHERE rg.object_id = @ObjectID
2967
+
AND c.name IN ( '+ @ColumnListWithApostrophes +N')'
0 commit comments