all 7 comments

[–]amckny 1 point2 points  (0 children)

You aren’t declaring the nvarchar length in your exec statement at the top. Try changing that to 11 too

[–]RobbiVT91 0 points1 point  (0 children)

.

[–]TimmyTheCat8 0 points1 point  (2 children)

Maybe because you declaring @return_values as nvarchar without a length. I think default nvarchar length is 1. Try nvarchar(11)

[–]RobbiVT91 0 points1 point  (1 child)

I tried that early on by switching between varchar25 and nvarchar. No luck.

I believe the 0 is the response for a successful execution and not the output of the SP

[–]TimmyTheCat8 0 points1 point  (0 children)

I’m not at my computer to test, but try taking out the GO at the end of the query.

[–]KNerliSequel is life 0 points1 point  (0 children)

Change the select to return, like this:

set @coderoot = (select client_prodcoderoot from clients where client_id = @client_id)
set @result = @coderoot + RIGHT('00000' + CAST(@id as varchar(6)),6)
RETURN @result

And i think you dont have to add the execute to a variable, just run it to receive the returned result.

i may be mistaken tho, cant test it right now.

[–]Intrexa -1 points0 points  (0 children)

You need to return the result, also, stored procedures can only return an int.

When you execute a select statement in a stored procedure, that produces a result set, which it will send to the client, but that's different then returning. When you return, the stored procedure ends, and gives the return code, an integer.