From: Mario on
I have identity int column with increment 1 and seed 1.
I wish to reseed ID column when I delete some rows and inserting new
one. I try to create trigger like this one:

ALTER TRIGGER Trigger2
ON Table2
FOR DELETE
AS
/*IF UPDATE(id) */
DBCC CHECKIDENT ('Table2', RESEED)

But inserting continuous with the next int value in ID column, although
I deleted some rows.

How to reseed my ID column with the last one existing in a database?
From: PvdG42 on

"Mario" <pascal(a)po.t-com.hr> wrote in message
news:hhi43s$qen$1(a)ss408.t-com.hr...
> I have identity int column with increment 1 and seed 1.
> I wish to reseed ID column when I delete some rows and inserting new one.
> I try to create trigger like this one:
>
> ALTER TRIGGER Trigger2
> ON Table2
> FOR DELETE
> AS
> /*IF UPDATE(id) */
> DBCC CHECKIDENT ('Table2', RESEED)
>
> But inserting continuous with the next int value in ID column, although I
> deleted some rows.
>
> How to reseed my ID column with the last one existing in a database?

You're more likely to get useful responses if you ask in a discussion group
for the DBMS you are using. This group is for .NET programming questions.

If you are using SQL Server, there are numerous groups that begin with:

microsoft.public.sqlserver

where you'll quickly get the assistance you need.


From: Gregory A. Beamer on
Mario <pascal(a)po.t-com.hr> wrote in news:hhi43s$qen$1(a)ss408.t-com.hr:

> I have identity int column with increment 1 and seed 1.
> I wish to reseed ID column when I delete some rows and inserting new
> one. I try to create trigger like this one:
>
> ALTER TRIGGER Trigger2
> ON Table2
> FOR DELETE
> AS
> /*IF UPDATE(id) */
> DBCC CHECKIDENT ('Table2', RESEED)
>
> But inserting continuous with the next int value in ID column,
> although I deleted some rows.
>
> How to reseed my ID column with the last one existing in a database?


If you are deleting all the ending rows, then this is useful ...
perhaps. it is more useful for human dynmics than anything else. If you
are deleting out of "random" spots in the table, this will have no
effect.

NOTE: The CHECKIDENT works best, for the purpose you desire, when you
actually set up a reseed value.

Having "holes" in a table should not matter, except to humans who look
at them. And reseeding after deletion has some possible disastrous
effects, esp. if you have not been diligent with your referential
integrity.

Peace and Grace,


--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
From: Gregory A. Beamer on
"PvdG42" <pvdg42(a)toadstool.edu> wrote in
news:eMswcljiKHA.1540(a)TK2MSFTNGP06.phx.gbl:

> You're more likely to get useful responses if you ask in a discussion
> group for the DBMS you are using. This group is for .NET programming
> questions.
>
> If you are using SQL Server, there are numerous groups that begin
> with:
>
> microsoft.public.sqlserver
>
> where you'll quickly get the assistance you need.

People see .General and ignore everything else. ;-)

Peace and Grace,

--
Gregory A. Beamer (MVP)

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
From: Mario on
On 31.12.2009. 18:20, Gregory A. Beamer wrote:
> "PvdG42"<pvdg42(a)toadstool.edu> wrote in
> news:eMswcljiKHA.1540(a)TK2MSFTNGP06.phx.gbl:
>
>> You're more likely to get useful responses if you ask in a discussion
>> group for the DBMS you are using. This group is for .NET programming
>> questions.
>>
>> If you are using SQL Server, there are numerous groups that begin
>> with:
>>
>> microsoft.public.sqlserver
>>
>> where you'll quickly get the assistance you need.
>
> People see .General and ignore everything else. ;-)
>
> Peace and Grace,
>
Ok. To redefine a question ie to ask another thing I need is how to fill
the first column of the ListView with the row number? Consist the row
deleting.