Friday, March 23, 2012

purpose of OUTPUT keyword in sql server

hello sirs
purpose OUTPUT keyword with examplessurya (suryaitha@.gmail.com) writes:
> hello sirs
> purpose OUTPUT keyword with examples

You use OUTPUT to specify that a parameter is an output parameter:

CREATE PROCEDURE getordercount @.custid int, @.cnt OUTPUT AS
SELECT @.cnt = COUNT(*) FROM orders WHERE custid = @.custid

What is special with T-SQL, is that you need to specify OUTPUT also when you
call the procedure:

EXEC getordercount @.custid, @.cnt OUTPUT

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

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Erland,

you said right about OUTPUT parameters...
but what about the OUTPUT clause of
DELETE, INSERT and UPDATE statements
in SQL Server 2005?

surya, for more details about the OUTPUT clause see the following link:
http://msdn2.microsoft.com/en-us/library/ms177564.aspx

--
Andrey Odegov
avodeGOV@.yandex.ru
(remove GOV to respond)|||avode (avode_spam@.yahoo.com) writes:
> you said right about OUTPUT parameters...
> but what about the OUTPUT clause of
> DELETE, INSERT and UPDATE statements
> in SQL Server 2005?

Sorry! There's so much new stuff, that I tend to forget some of it.
The OUTPUT clause in one of the more obscure items.

> surya, for more details about the OUTPUT clause see the following link:
> http://msdn2.microsoft.com/en-us/library/ms177564.aspx

...and if it was in that context you asked about OUTPUT, surya, please
tell us if you want more clarifcation.

Thanks for posting the link Andrey.

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

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx

No comments:

Post a Comment