Friday, February 17, 2012

Error Hanlde in sp

Hi all,
i am new .. please help.
I am creating a list of random id's .. I have my table and I use the Rand co
mand and multiply up to the appropriate size. then use round to give an inte
ger value.
ie @.Value = Round((Rand * 20000000) + 10000000)
The table's ID field is a primary key so at some point the random number gen
erator will repeat some of the numbers.
In VB I would use an error handler such as 'on error resume next'.. how do
I do this in an sp.
I ask this because my ID base is 30 million and writing it in vb to insert i
nto sql will take forever.
Thanks in advance RussHi Russ,
Can you give some more information about what you are trying to do? A table
schema and what the exact (business) purpose is of generating random ids is
what I am after. I have a few possible solutions in mind, and if you provide
me with this information, I can hopefully provide you with a complete script
that will solve your problem.
Jacco Schalkwijk
SQL Server MVP
"Russ" <anonymous@.discussions.microsoft.com> wrote in message
news:AC8BF4C9-A62B-4EB6-84E5-3E86807C186C@.microsoft.com...
>
> Hi all,
> i am new .. please help.
> I am creating a list of random id's .. I have my table and
I use the Rand comand and multiply up to the appropriate size. then use
round to give an integer value.
> ie @.Value = Round((Rand * 20000000) + 10000000)
> The table's ID field is a primary key so at some point the
random number generator will repeat some of the numbers.
> In VB I would use an error handler such as 'on error resume
next'.. how do I do this in an sp.
> I ask this because my ID base is 30 million and writing it
in vb to insert into sql will take forever.
>
> Thanks in advance Russ

No comments:

Post a Comment