Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
cwburke
Starting Member
16 Posts |
Posted - 2002-04-09 : 14:24:05
|
I have an application that will be used by multiple users. This application will create a new barcode number for each unit that is processed. I use the following code to generate the next barcode number. The objective here is to not allow two or more users simultaneous access to the table at the same time, thus eliminating the possibility of duplicate barcodes. Is the following statement the most effecient way to lock the table, generate the new barcode, update the table, then return the new barcode to the calling app:Begin TranSelect @Barcode=barcode+1From tbl_pwe_svc_fsc_ref_barcodeWith (TabLock, HoldLock)Update tbl_pwe_svc_fsc_ref_barcodeSet barcode = @BarcodeSelect barcodeFrom tbl_pwe_svc_fsc_ref_barcodeCommit tran Thanks for your help,Chris |
|
|
AjarnMark
SQL Slashing Gunting Master
3246 Posts |
Posted - 2002-04-09 : 18:54:56
|
| Duplicate Post. See [url]http://www.sqlteam.com/Forums/topic.asp?TOPIC_ID=14747[/url] for answers.Lock please.------------------------GENERAL-ly speaking... |
 |
|
|
|
|
|