要将 SQL INT 值拆分为多行,您可以使用以下方法:
DECLARE @start_value INT = 1;
DECLARE @end_value INT = 10;
WITH
Numbers AS (
SELECT @start_value AS num
UNION ALL
SELECT num + 1
FROM Numbers
WHERE num < @end_value
)
SELECT * FROM Numbers;
DECLARE @start_value INT = 1;
DECLARE @end_value INT = 10;
WHILE @start_value <= @end_value
BEGIN
SELECT @start_value AS num;
SET @start_value = @start_value + 1;
END;
DECLARE @start_value INT = 1;
DECLARE @end_value INT = 10;
SELECT num
FROM (
SELECT @start_value + ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) - 1 AS num
FROM sys.objects
) AS Numbers
WHERE num <= @end_value;
这些方法可以帮助您将 SQL INT 值拆分为多行,以便在查询中使用。请注意,这些方法可能需要根据您的具体需求进行调整。
领取专属 10元无门槛券
手把手带您无忧上云