I have a query that I used pull data from several different tables each night and this pull goes into an upsert table that is loaded to our cloud server. I am trying to set some type of unique identifer/primary key for each row, but I am having issues with it.
SELECT SUBSTRING(CAST(NEWID() AS varchar(38)), 1, 16)
Whenever I rerun the query, it changes the value of the NEWID()
each time, so it's loading duplicates into my table every night instead of updating the records. Is there anyway I can keep newid()
as static value every time I run the query?
Thanks, Rachel