Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
how can i maintain a unique key into the database while saving requestId into the database. RequestId that means for every request generated by client to server there should be an unique id. currently I am using Guid for id but guid generates a complicated string as id
please help me
thanks in advance
Posted
Updated 13-Mar-15 12:27pm
v2
Comments
barneyman 12-Mar-15 1:44am    
guid is the correct solution if you want it globally unique - why does the fact it's a complicated string (it's not a string, that's just how the UI renders it) matter?
Maciej Los 14-Mar-15 9:49am    
What version of MS SQL Server?

GUID is the commonly used solution. If you dont like it then try process id with thread id and append timestamp.
 
Share this answer
 
you acn use another table to hold on the globel id.

table_globel_id<br />
@id as bigint


whenever inserting to any table use ID from this table
like: select isnull(id,0) from table_globel_id

and whenever complitiong the sql query/transaction increase the value of the id in table_globel_id.

like:
SQL
if exixt(select * from table_globel_id)
 then 
update table_globel_id set id=id+1
else
insert into table_globel_id(id)=1 
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900