Sunday, March 25, 2012

Customer IDs without identity

I am aware of the problems with using identity. I would like a bit
more information on implementation. Concurency is a concern because
this is a net application.

Do I do this at the application level, in a trigger, or using another
method?

I want to make sure that the method I choose is robust and maintains
the integrity of the data.

>From what I know, in this case not much, it would seem that the
trigger is the best bet.

If I were to do a table that stores the unique number counter, I'm
thinking TableName and NextNumber fields could be created and then
used for all tables that need this requirement. Then my trigger
would look up the next number based on its table name, save the
number as the ID and then increment the value by 1 or whatever step
I choose. Is this thread safe?

Thanks,
GregHi

There are several replies in microsoft.public.sqlserver.programming. Please
do not cross post unlinked messages.

John

"yzarc" <yzarcman@.gmail.com> wrote in message
news:1114974498.504826.28590@.z14g2000cwz.googlegro ups.com...
>I am aware of the problems with using identity. I would like a bit
> more information on implementation. Concurency is a concern because
> this is a net application.
> Do I do this at the application level, in a trigger, or using another
> method?
> I want to make sure that the method I choose is robust and maintains
> the integrity of the data.
>>From what I know, in this case not much, it would seem that the
> trigger is the best bet.
> If I were to do a table that stores the unique number counter, I'm
> thinking TableName and NextNumber fields could be created and then
> used for all tables that need this requirement. Then my trigger
> would look up the next number based on its table name, save the
> number as the ID and then increment the value by 1 or whatever step
> I choose. Is this thread safe?
> Thanks,
> Greg|||Im sorry didn't think x posting was acceptable. I also didn't know how
to do it from google.

John Bell wrote:
> Hi
> There are several replies in microsoft.public.sqlserver.programming.
Please
> do not cross post unlinked messages.
> John
> "yzarc" <yzarcman@.gmail.com> wrote in message
> news:1114974498.504826.28590@.z14g2000cwz.googlegro ups.com...
> >I am aware of the problems with using identity. I would like a bit
> > more information on implementation. Concurency is a concern because
> > this is a net application.
> > Do I do this at the application level, in a trigger, or using
another
> > method?
> > I want to make sure that the method I choose is robust and
maintains
> > the integrity of the data.
> >>From what I know, in this case not much, it would seem that the
> > trigger is the best bet.
> > If I were to do a table that stores the unique number counter, I'm
> > thinking TableName and NextNumber fields could be created and then
> > used for all tables that need this requirement. Then my trigger
> > would look up the next number based on its table name, save the
> > number as the ID and then increment the value by 1 or whatever step
> > I choose. Is this thread safe?
> > Thanks,
> > Greg|||yzarc (yzarcman@.gmail.com) writes:
> Im sorry didn't think x posting was acceptable. I also didn't know how
> to do it from google.

Cross-posting is far better than multi-posting. Hadn't John posted this
note, I would have spent time to compose a reply, which would have been
a waste of time if you already had received response. Had you cross-posted,
the replies would most likely also have been cross-posted. No, I don't
know how to cross-post on Google.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techin.../2000/books.asp|||Hi

When you post in Google it says under the newsgroup box (Separate multiple
groups with commas)
so I guess that is what you need to do!

I should have said multi-post, but the correct name escaped me at the time!

John

"yzarc" <yzarcman@.gmail.com> wrote in message
news:1114980047.705625.16530@.o13g2000cwo.googlegro ups.com...
> Im sorry didn't think x posting was acceptable. I also didn't know how
> to do it from google.
> John Bell wrote:
>> Hi
>>
>> There are several replies in microsoft.public.sqlserver.programming.
> Please
>> do not cross post unlinked messages.
>>
>> John
>>
>> "yzarc" <yzarcman@.gmail.com> wrote in message
>> news:1114974498.504826.28590@.z14g2000cwz.googlegro ups.com...
>> >I am aware of the problems with using identity. I would like a bit
>> > more information on implementation. Concurency is a concern because
>> > this is a net application.
>>> > Do I do this at the application level, in a trigger, or using
> another
>> > method?
>>> > I want to make sure that the method I choose is robust and
> maintains
>> > the integrity of the data.
>>> >>From what I know, in this case not much, it would seem that the
>> > trigger is the best bet.
>>> > If I were to do a table that stores the unique number counter, I'm
>> > thinking TableName and NextNumber fields could be created and then
>> > used for all tables that need this requirement. Then my trigger
>> > would look up the next number based on its table name, save the
>> > number as the ID and then increment the value by 1 or whatever step
>> > I choose. Is this thread safe?
>>> > Thanks,
>> > Greg
>

No comments:

Post a Comment