I need to create a list of GUID's in SQL Server 2008 R2 and I am using the NEWID()
function.
This is what I am trying but I just get only one ID:
SELECT TOP 100 NEWID()
I am new to SQL Server and I don't know if there is a way to do that or a way to create a loop for do it.
I don't need to persist those GUID's I just want to show them on screen.
You can use an arbitrary table as "sequence-generator":
SELECT TOP (100) Guid = NEWID()
FROM [master]..spt_values;
Demo
Note that this table contains only 2346 rows.
Worth reading: Generate a set or sequence without loops
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