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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Returning Value from Stored Procedure

Author  Topic 

Razmo
Starting Member

5 Posts

Posted - 2010-05-05 : 11:31:10
I'm having problems viewing the results of a return value from a procedure. This is the procedure:

CREATE PROCEDURE usp_GetCountyName (
@nStateID INT,
@nCountyID INT,
@cCountyName NVARCHAR(50) OUTPUT)
AS
SELECT @cCountyName = Name
FROM County
WHERE State_ID = @nStateID AND
County_ID = @nCountyID
GO

This is the table containing the data:

State_ID County_ID Name
64 32 SALT LAKE

This compiles without complaints.

This is how I'm executing:

DECLARE @cName NVARCHAR(50), @cCountyName NVARCHAR(50)

EXECUTE usp_GetCountyName
@nStateID = 64,
@nCountyID = 32,
@cCountyName = ''

SELECT @cName = @cCountyName
print @cName

GO

No results are returned. ???

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-05-05 : 11:39:51
[code]
DECLARE @cName NVARCHAR(50), @cCountyName NVARCHAR(50)

EXECUTE usp_GetCountyName
@nStateID = 64,
@nCountyID = 32,
@cCountyName = @cName OUTPUT

SELECT @cName = @cCountyName
print @cName
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Razmo
Starting Member

5 Posts

Posted - 2010-05-05 : 11:48:40
That worked great! Thank you for your assistance.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-05-05 : 11:49:55
you are welcome


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-05-05 : 14:49:26
also see this

http://www.sqlteam.com/article/stored-procedures-returning-data

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -