I have a table A which consists more than 7k records,Now i am creating a new table B .In my new table B I need to copy only 1000 records from table A which has more than 7000 records.
No condition applies, it may be any thousand records from 7000 .
I have a table A which consists more than 7k records,Now i am creating a new table B .In my new table B I need to copy only 1000 records from table A which has more than 7000 records.
No condition applies, it may be any thousand records from 7000 .
In SQL Server
In MySQL
You can use
ROW_NUMBER
in a common table expression.Then it's easy to change the logic what should be exported. You could change the
ORDER BY
, apply aPARTITION BY
(f.e. to copy duplicates), use multipleORDER BY
comma separated or change the number you want to export.