我想使用此查询但每次执行时结果都是空的。你知道为什么吗?
DECLARE @name VARCHAR(50)
DECLARE db_cursor CURSOR FOR
SELECT name FROM sys.tables
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @name
WHILE @@FETCH_STATUS = 0
BEGIN
SELECT
s.name AS statistics_name,
c.name AS column_name,
sc.stats_column_id
FROM
sys.stats AS s
INNER JOIN
sys.stats_columns AS sc ON s.object_id = sc.object_id
AND s.stats_id = sc.stats_id
INNER JOIN
sys.columns AS c ON sc.object_id = c.object_id
AND c.column_id = sc.column_id
WHERE
s.object_id = OBJECT_ID('@name');
FETCH NEXT FROM db_cursor INTO @name
END
非常感谢,
大卫。