Group numbering

,

An easy way to organize the data by groups of sequential numbers. This is very helpful for splitting up a large file into numerous smaller files. You can then create the smaller files by filtering for the row number per file.

SELECT *,case when convert(int,id)% 3 =  0 then 3 else convert(int,id)% 3 end as rowno
FROM testfile

-- RESULTS:
…………....     rowno
           ---------
		1
		2
		3
		1
		2
		3
		1
		2
		3
		.
		.	    
-- You can substitute the 3 to any number, or you can write a stored procedure that will accept a variable number, to divide your big file into.

Rate

Share

Share

Rate