I hope you all can help me.
What I'm trying to do
I'm trying to take a random sample from a large Azure database so that I can run the files locally before deploying on Azure cloud. The steps are to first create a pseudorandom number, then just take the first X rows or first X% of rows.
What I've tried
I've read several posts including stack overflow SQL, stack overflow SQL 2, SQL select, and USQL Order By Fetch, but still have not figured the syntax out.
Code:
//ATTEMPT 1
SELECT * FROM @searchlog
FETCH FIRST 3 ROWS ONLY;
//ATTEMPT 2
@outsearchlog =
SELECT *
FROM @searchlog
ORDER BY NEWID() DESC FETCH 10;
//ATTEMPT 3
@outsearchlog =
SELECT *,
NEWID() AS newid
FROM @searchlog;
//ATTEMPT 4
@outsearchlog =
SELECT *,
newid() AS newid
FROM @searchlog;
//ATTEMPT 5
@outsearchlog =
SELECT *,
newid() AS newidwoot
FROM @searchlog;
//ATTEMPT 6
@outsearchlog =
SELECT *,
Random() AS newidwoot
FROM @searchlog;