Friday, February 24, 2012

how i can skip error messeges within Procedures

how i can skip error messeges within Procedures
such as can't insert to duplicate keys
thanks
samEither *handle* errors or *avoid* them, but don't *skip* them.
It sounds like you should avoid inserting duplicate keys in the first
place. Example:
INSERT INTO YourTable (c1, c2, ...)
SELECT @.c1, @.c2, ...
WHERE NOT EXISTS
(SELECT *
FROM YourTable
WHERE c1 = @.c1) ;
Error handling:
http://www.sommarskog.se/error-handling-I.html
David Portas
SQL Server MVP
--|||Your insert failed, why would you want to ignore that?
How about preventing the error in the first place?
http://www.aspfaq.com/2509
"Sam" <focus10@.zahav.net.il> wrote in message
news:e6uyl5QmFHA.3648@.TK2MSFTNGP10.phx.gbl...
> how i can skip error messeges within Procedures
> such as can't insert to duplicate keys
> thanks
> sam
>
>|||Can't be done <yet>. All messages in SQL Server get sent to the client.
You cannot stop them....<yet>
----
Louis Davidson - http://spaces.msn.com/members/drsql/
SQL Server MVP
"Sam" <focus10@.zahav.net.il> wrote in message
news:e6uyl5QmFHA.3648@.TK2MSFTNGP10.phx.gbl...
> how i can skip error messeges within Procedures
> such as can't insert to duplicate keys
> thanks
> sam
>
>

No comments:

Post a Comment