Click here to Skip to main content
15,890,123 members
Home / Discussions / Database
   

Database

 
GeneralRe: enisey data scripter Pin
obs12322-Sep-10 21:25
professionalobs12322-Sep-10 21:25 
Questioninsert farsi into tables Pin
Shaahinm17-Nov-07 21:53
Shaahinm17-Nov-07 21:53 
AnswerRe: insert farsi into tables Pin
joemonvarghese18-Nov-07 18:44
joemonvarghese18-Nov-07 18:44 
GeneralRe: insert farsi into tables Pin
Shaahinm20-Nov-07 23:25
Shaahinm20-Nov-07 23:25 
AnswerRe: insert farsi into tables Pin
Mark Churchill19-Nov-07 14:37
Mark Churchill19-Nov-07 14:37 
QuestionRefreshing Identity Pin
Xmen Real 17-Nov-07 20:09
professional Xmen Real 17-Nov-07 20:09 
AnswerRe: Refreshing Identity Pin
Colin Angus Mackay18-Nov-07 2:53
Colin Angus Mackay18-Nov-07 2:53 
AnswerRe: Refreshing Identity Pin
DQNOK19-Nov-07 12:29
professionalDQNOK19-Nov-07 12:29 
Well, if you really can't sleep at night because of holes in your identity sequence, then you can manually assign IDs to new records (although this might require turning off your sequencer, or removing the "IDENTITY" attribute, then re-initializing it afterward) and use-up those holes.

Some months back, someone much smarter than I (Michael Potter[^]) suggested something similar to the following to find holes within a sequence.

SELECT TOP 1 Missing.ID 
FROM       (SELECT (ID - 1) AS ID  
            FROM   tblMyTable  
            WHERE  ID  > @startnum  
            ORDER BY ID) AS Missing  
LEFT JOIN  (SELECT ID  
            FROM   tblMyTable  
            ORDER BY ID) AS Includes 
     ON Missing.ID = Includes.ID
WHERE Includes.ID IS NULL;

You could just turn off your sequence entirely, and use the return from the above when it is not null, then when it does return null, use the following.
SELECT MAX(ID)+1 FROM myTable;

However, there are issues with not using the DB provided sequencer. For example, you'll have to make sure concurrency works correctly. This may involve locking tables, etc.


David
---------
Empirical studies indicate that 20% of the people drink 80% of the beer. With C++ developers, the rule is that 80% of the developers understand at most 20% of the language. It is not the same 20% for different people, so don't count on them to understand each other's code.
http://yosefk.com/c++fqa/picture.html#fqa-6.6
---------

GeneralRe: Refreshing Identity Pin
Xmen Real 19-Nov-07 14:30
professional Xmen Real 19-Nov-07 14:30 
GeneralRe: Refreshing Identity Pin
DQNOK20-Nov-07 3:51
professionalDQNOK20-Nov-07 3:51 
GeneralRe: Refreshing Identity Pin
Xmen Real 20-Nov-07 14:33
professional Xmen Real 20-Nov-07 14:33 
GeneralRe: Refreshing Identity Pin
DQNOK21-Nov-07 3:49
professionalDQNOK21-Nov-07 3:49 
GeneralRe: Refreshing Identity Pin
Xmen Real 21-Nov-07 4:20
professional Xmen Real 21-Nov-07 4:20 
GeneralRe: Refreshing Identity [modified] Pin
Xmen Real 21-Nov-07 16:40
professional Xmen Real 21-Nov-07 16:40 
GeneralRe: Refreshing Identity Pin
DQNOK26-Nov-07 3:46
professionalDQNOK26-Nov-07 3:46 
GeneralRe: Refreshing Identity Pin
Xmen Real 26-Nov-07 4:33
professional Xmen Real 26-Nov-07 4:33 
QuestionExecute String sql Pin
SVb.net17-Nov-07 4:31
SVb.net17-Nov-07 4:31 
AnswerRe: Execute String sql Pin
andyharman17-Nov-07 10:52
professionalandyharman17-Nov-07 10:52 
AnswerRe: Execute String sql Pin
JM_G18-Nov-07 9:15
JM_G18-Nov-07 9:15 
Questionhow to fill DataAdapter when two tables are being used+ASP.Net Pin
mavii17-Nov-07 1:29
mavii17-Nov-07 1:29 
AnswerRe: how to fill DataAdapter when two tables are being used+ASP.Net Pin
pmarfleet17-Nov-07 2:50
pmarfleet17-Nov-07 2:50 
Questionfind the count(empid) from view and count(querriid) from tabel by using InnerJoins Pin
subbu.sk16-Nov-07 23:32
subbu.sk16-Nov-07 23:32 
AnswerRe: find the count(empid) from view and count(querriid) from tabel by using InnerJoins Pin
pmarfleet17-Nov-07 2:49
pmarfleet17-Nov-07 2:49 
QuestionReplication - suggesstions/links. [modified] Pin
GuyThiebaut16-Nov-07 22:21
professionalGuyThiebaut16-Nov-07 22:21 
AnswerRe: Replication - suggesstions/links. Pin
Hesham Amin18-Nov-07 11:04
Hesham Amin18-Nov-07 11:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.