sql - Ensure unique value -


i have table unique values within , once stored procedure called, use following code within sub-query random value table:

select top 1 uniqueid uniquevalues initiatingid null order newid() asc 

i have noticed managing , (and i'm guessing 2 calls running simultaneously cause it) retrieve same unique value twice, causes issues within program.

is there way (preferably not locking table) make unique values id generation unique - or unique enough not affect 2 simultaneous calls? note, need keep unique values , cannot use guids directly here.

thanks,

kyle


edit clarification:

i buffering unique values. that's where initiatingid null about. value gets picked out of query, initiatingid set , therefore cannot used again until released. problem in milliseconds of process setting initiatingid seems value getting picked again, harming process.

random implies same value twice randomly.

why not using identity columns?

i wrote blog post manual id generation days ago here. maybe helps.


Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -