Have a look at similar questions and answers:
split data into 2 gridview tables[
^]
How do I split a table over 2 pages?[
^]
Split datatable into multiple tables[
^]
I hope this is what you're looking for...
[EDIT #1]
This day was a rainy sunday, so i had a time for fun with SQL. This is what i had done:
CREATE TABLE #tmp (MIVID INT, Quantity INT, [Value] INT)
INSERT INTO #tmp (MIVID, Quantity, [Value])
SELECT 1 AS MIVID, 10 AS Quantity, 3000 AS [Value]
UNION ALL SELECT 1, 20, 3500
UNION ALL SELECT 1, 15, 2000
UNION ALL SELECT 2, 20, 3000
UNION ALL SELECT 2, 50, 7500
UNION ALL SELECT 3, 25, 2000
DECLARE @commands TABLE (ID INT, command VARCHAR(MAX))
INSERT INTO @commands (ID, command)
SELECT DISTINCT MIVID AS ID, 'SELECT * FROM #tmp WHERE MIVID = ' + CONVERT(VARCHAR(10),MIVID) AS command
FROM #tmp
DECLARE @sql VARCHAR(255)
DECLARE sql_cursor CURSOR
FOR SELECT command FROM @commands
OPEN sql_cursor
FETCH NEXT FROM sql_cursor INTO @sql;
WHILE @@FETCH_STATUS=0
BEGIN
PRINT @sql
EXEC(@sql)
FETCH NEXT FROM sql_cursor INTO @sql;
END
CLOSE sql_cursor
DEALLOCATE sql_cursor
DROP TABLE #tmp
Result: 3 data-sets - exactly as you expect ;)