I am using Microsoft SQL Server Management Studio, I have minimal expertise in SQL Server but I have used MySQL in the past and pretty good at it.
My question is: I have a rather large database with over 130m+ records.
I wish to only get the URL column but every single record in this column.
Microsoft SQL Server Management Studio jams up when saving to a file due to one error or another so I have come to the conclusion that I need to do this in chunks.
I am running this command at the moment and saving to file
SELECT TOP 20000000 [URL]
FROM [dbo].[siteentry]
WHERE [Content] LIKE ''
However when this command finishes I have 0 clue how to skip the first 20,000,000 and continue onto the next batch of 20,000,000 without killing the server.
Any help would be great.
With SQL Server 2012, you can use the OFFSET...FETCH
commands:
SELECT [URL]
FROM [dbo].[siteentry]
WHERE [Content] LIKE ''
ORDER BY (some column)
OFFSET 20000 ROWS
FETCH NEXT 20000 ROWS ONLY
For this to work, you must order by some column in your table - which you should anyway, since a TOP ....
without an ORDER BY
is useless - you'll get back arbitrary rows
You can use an "offset" to skip the rows. Check https://technet.microsoft.com/en-us/library/gg699618(v=sql.110).aspx for more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With