SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Trigger
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

JmaC
Starting Member

Malaysia
18 Posts

Posted - 08/27/2010 :  00:19:38  Show Profile  Reply with Quote
hi all...

i have registration form with button DELETE,EDIT,INSERT..
All working fine...

example table:

i have table with 5rows...
1 | Peter
2 | James
3 | Helen
4 | Nickles
5 | John

if i delete ID 3 (3|Helen) from table...

1 | Peter
2 | James
4 | Nickles
5 | John


now am going to register new person...
what i need is when i click INSERT button in form ID:3 have to appear automatically in textbox/dropdownlist to register new person.(use deleted ID for register new person).

i write coding for get ID:6 and it's working good...

SELECT min(PANG)
FROM (SELECT AccNo + 1 AS PANG FROM debtor EXCEPT SELECT AccNo FROM Debtor)
AS boon WHERE PANG >300000000

the problem is:
1) What if there are two users clicking INSERT? Both will be suggested ID:3


I create trigger to solve this problem...

CREATE TRIGGER TGRDebtor
ON dbo.Debtor
FOR UPDATE
AS
IF ()


END
go

can anyone help me out....


Thanks & Regards
JmaC

Edited by - JmaC on 08/27/2010 00:21:10

visakh16
Very Important crosS Applying yaK Herder

India
52309 Posts

Posted - 08/28/2010 :  01:01:52  Show Profile  Reply with Quote
why should you put new record in deleted position? it will not preserve the sequence of insertion and in case you want to retrieve records in inserted order you would have no way to do that unless you've some audit columns. I dont really think you need to worry about gaps in ID values.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000