Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old March 24th, 2006, 10:21 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default Output Parameters

Hello,

How do I call the following proc from Query Analyzer? Something like:

EXEC procOutGetCustomer 'ALFKI', ?, ?, ?

The proc is:

CREATE PROCEDURE procOutGetCustomer(
    @CustomerID nchar(5),
    @CompanyName nvarchar(40) OUTPUT,
    @ContactName nvarchar(30) OUTPUT,
    @ContactTitle nvarchar(30) OUTPUT)
AS SELECT
    @CompanyName = CompanyName,
    @ContactName = ContactName,
    @ContactTitle = ContactTitle
FROM
    Customers
WHERE
    CustomerID = @CustomerID
IF @@ROWCOUNT = 1
    RETURN 0
ELSE
    RETURN -1;

Thanks,

Bob



Reply With Quote
  #2 (permalink)  
Old March 25th, 2006, 05:26 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

You need to decalre variables to receive the output and specify that they are of type OUTPUT:
Code:
DECLARE @CompanyName NVARCHAR(40) 
DECLARE @ContactName NVARCHAR(30)
DECLARE @ContactTitle NVARCHAR(30) 
EXEC procOutGetCustomer 'ALFKI', @CompanyName OUTPUT, @ContactName OUTPUT, @ContactTitle OUTPUT
PRINT 'CompanyName: ' + @CompanyName
PRINT 'ContactName: ' + @ContactName
PRINT 'ContactTitle: ' + @ContactTitle
--

Joe (Microsoft MVP - XML)
Reply With Quote
  #3 (permalink)  
Old March 25th, 2006, 06:32 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Thanks, Joe. Much appreciated.

Bob

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Output Parameters: I can't be this stupid... raysot BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 13 May 20th, 2010 07:28 PM
Chapter 6 "Using SQL Output Parameters..." burkecrosby BOOK: Professional SQL Server 2005 Integration Services ISBN: 0-7645-8435-9 22 February 10th, 2010 05:33 PM
output parameters with the objectdatasource trancehead ASP.NET 2.0 Professional 2 August 25th, 2008 12:41 PM
OUTPUT Parameters saulodet ADO.NET 0 May 14th, 2004 10:02 AM
SQL output parameters ohiggs SQL Server 2000 4 February 9th, 2004 10:09 PM



All times are GMT -4. The time now is 01:08 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.