Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
paradise_wolf
Starting Member
32 Posts |
Posted - 2007-02-05 : 06:53:11
|
CREATE PROCEDURE VerifyIfInvoiceExists(@Invoice VARCHAR(50))ASDECLARE @DoesExist BITIF EXISTS (SELECT NULL FROM IPN_receivedWHERE Invoice = @Invoice)SELECT @DoesExist = 1ELSE SELECT @DoesExist = 0~~~~~~~~~~~~~~~~~~~~~~~~~~~~~I am getting an exception error. Any clue ? |
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-05 : 07:00:50
|
what is the error message ?This is what you want ?CREATE PROCEDURE VerifyIfInvoiceExists( @Invoice VARCHAR(50), @DoesExist BIT OUTPUT)ASIF EXISTS (SELECT NULL FROM IPN_received WHERE Invoice = @Invoice) SELECT @DoesExist = 1ELSE SELECT @DoesExist = 0 KH |
|
|
Kristen
Test
22859 Posts |
Posted - 2007-02-05 : 07:03:38
|
"IF EXISTS (SELECT NULL FROM IPN_received ..."Nothing to do with raising an error, but the convention is to use:IF EXISTS (SELECT * FROM IPN_received ...which is intended to allow SQL Server to choose which column / index / etc. it uses to satisfy the query.Kristen |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
|
|
|
|