DECLARE @min NUMERIC(18, 0) DECLARE @max NUMERIC(18, 0) DECLARE @parts NUMERIC(18, 0) SELECT @min = 102201011472463 ,-- Minimum value in your range of values @max = 102201354392808 ,-- Maximum value in your range of values @parts = 3480 --Give number of parts DECLARE @increment INT = (@max - @min) / @parts WHILE @max >= @min BEGIN DECLARE @newMin NUMERIC(18, 0) = @min + @increment PRINT convert(VARCHAR, @min) + ' - ' + convert(VARCHAR, @newMin) SELECT @min = @newMin + 1 END
Tuesday, September 23, 2014
Script to split given range of values in to desired number of parts in SQL Server
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment