Click here to Skip to main content
15,901,284 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear mentors,
This is my first posting here, though, i have learnt a lot from here.

I have a table "tblUserRequest" in sql server express 2005 database and vb.net 2008 application in front end. Table structure is the following: RequestID, UserID, RequestBody.

Users are submitting their queries in tblUserRequest. My question is what is the best policy to create RequestID? Shall i create new id from vb app then save all the data, or use stored procedure?

My objective is to ensure that no duplicate value is inserted. I don't want to use auto increment datatype.

Sorry for my poor language.

SKPaul
Posted

1 solution

Take a look at the below mentioned links.

I think you can make use of one of them.

Random Number Generation Methods[^]

Random Number Generation Using SQL Server [^]

Hope these links will help you.

BR//
Harsha
 
Share this answer
 
Comments
Saumitra Kumar Paul 25-May-11 8:05am    
Thank you Harsha. Random number is not useful in my case. RequestID field should be 1,2,3..n. As that table will receive huge request per minute, New RequestID creation in client side might generate duplicate value. I want to avoid it.
ZeeroC00l 25-May-11 8:06am    
Well in that case i suggest you go for stored procedure. You can generate your own custom ID and assign it. And that can be incremented in every insert / any other operation.
Saumitra Kumar Paul 25-May-11 8:08am    
Dear ZeeroCOOl,

Your's could be a good solution. Thank you.
Saumitra Kumar Paul 25-May-11 8:10am    
Would you please tell me why you are suggesting this?
ZeeroC00l 25-May-11 8:16am    
I can think of two reasons. 1) You can create a custom ID of your choice
2) You can avoid duplication of the ID 100%.

But this might increase the write time to table by a small amount. I cant exactly tell you about the performance in terms of time taken.

And, coming to the other point you mentioned in the question,about using the vb app.

That can be done too. But i think this would take more time in terms of performance compared to the one created using the stored procedure.

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