question

sand143eep avatar image
sand143eep asked

putting 1 lakh rows in 15 tables from a table having 15 lakh rows

there are 15 lakh records in a table. i want to create 15 tables with 1lakh rows in each table. is there any possibility by using select top 100000 into new table from original table and then select top 100001 to 200000 in to new table from original table. please guide how i can manage this

sql-server-2008-r2sql-server-2012
5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

we cant use where condition here, due to which I am struggling

0 Likes 0 ·

For those who don't know, 1 lakh = 100,000 (https://en.wikipedia.org/wiki/Lakh)

0 Likes 0 ·

You ask for help but only give use a couple of numbers with no details. Post the DDL for the source table and tell us what naming pattern you want for the 15 tables and what we should do an ORDER BY on to control the order. Also let us know which version of SQL Server you're actually working with... you have both 2008R2 AND 2012 selected as tags.

0 Likes 0 ·

A Thomas and ananth suggested used the limit and offset as follows:

SELECT employee_id,first_name,last_name FROM employees ORDER BYfirst_name LIMIT5OFFSET3;

which gave me required results. thanks for help.

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.