|
yogaboy -> RE: Can't get the OUTPUT from my sp! (4/3/2005 7:45:08)
|
Ok, it's fixed - thanks to Spooky and thanks to the author of the article on the end of the link. Here's the new code - just one or 2 lines different.
CREATE PROCEDURE dbo.uspInsertPersonalInvoice
(
@ClientID smallint = 6,
@InvoiceTotal smallmoney
)
AS
SET NOCOUNT ON
DECLARE @TheScope int
INSERT INTO dbo.Personal_Invoice
(DateCreated, ClientID, InvoiceTotal, DateSent)
VALUES
(GETDATE(), @ClientID, @InvoiceTotal, GETDATE())
SET @TheScope = SCOPE_IDENTITY()
SELECT [Returned Id] = @TheScope
SET NOCOUNT OFF and to call it
exec dbo.uspInsertPersonalInvoice
@ClientID = 6
, @InvoiceTotal = 257.96
Now, don't ask me why this works! I have a ton of SQL books here (or at least 20 kilos), I've trawled the net, I even went on a SQL Programming course last week (very good it was too) and I've been using the 2 ways, OUTPUT and RETURN, that all of these sources recommended. My code was synctatically correct and everything seemed right - except it didn't work! Typical[;)]
|
|
|
|