Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 2nd, 2004, 08:32 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default Multiple Return Values

I have a situation where I need two values (both are integers) returned from a stored procedure.

Right now, I use the statement return @@Identity for a single value, but there is another variable assigned in the procedure, @NewCounselingRecordID that I need to pass back to the calling class method.

I was thinking of concatenating the two values as a string and parsing them out after they are passed back to the calling method. It would look something like "21:17", with the colon character acting as a delimiter.

However, I feel this solution is kludgy. Is there a more correct way to accomplish this?

Thanks in advance for your comments.

- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.
 
Old June 2nd, 2004, 09:10 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,101
Thanks: 0
Thanked 2 Times in 2 Posts
Default

It's very cludgey...

You can select them - and not use the return:
SELECT @@IDENTITY
SELECT NewCounselingRecordID
and both would come back as two seperate "recordsets" that you could then use..

You could also use SQL parameters (like you would to pass in values to a Stored Procedure) for output.

Most people would probably say the second method was the cleaner version.


Hal Levy
Web Developer, PDI Inc.

NOT a Wiley/Wrox Employee
 
Old June 2nd, 2004, 09:11 AM
Friend of Wrox
 
Join Date: Oct 2003
Posts: 218
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks!

- - - - - - - - - - - - - - - - - - - - - - -
In God we trust, everything else we test.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using DoCmd.RunSQL to return values jscully Access VBA 10 August 21st, 2017 12:58 PM
Multiple Forms and the Return Key Focus rit01 ASP.NET 2.0 Basics 4 June 20th, 2006 01:44 PM
Return ASCII values for a given string sal C# 1 May 19th, 2005 03:59 PM
Listboxes with Multiple Values joanncae BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 October 13th, 2003 12:13 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.