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
 Simple Stored Procedure Issue

Author  Topic 

sbraudrick
Starting Member

5 Posts

Posted - 2008-09-27 : 21:17:19
I'm trying to write a simple stored procedure that returns a value. However, when I debug the procedure I get an "Syntax Error converting nvarchar to int" error message. This is my first procedure that returns a value, so I'm sure it's probably something simple that I have overlooked. Thanks in advance for your help.

The following is the procedure. Basically it is supposed to receive a value (SONum) and return the field "WebID".

CREATE PROCEDURE [dbo].[usp_GetWebIDfromSONum]

@SONum nvarchar(50)


AS

DECLARE @WebID nvarchar(50)

SET @WebID = (SELECT WebID
FROM Approvals
WHERE SONum = @SONum)

RETURN @WebID
GO

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-28 : 01:35:45
Stored procedures can ONLY have int values as return codes.

1) Make use of output parameters
or
2) Return the value as a resultset



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-28 : 02:38:30
Refer the below for various options for returning data from procedure
http://www.sqlteam.com/article/stored-procedures-returning-data
Go to Top of Page
   

- Advertisement -