question

fairyliquid2 avatar image
fairyliquid2 asked

Stored Proc and OUTPUT,Stored Proc OUTPUT

Hi I posted the original question last night and I'm now trying to apply it to the following: CREATE PROCEDURE [TIE].[CALLTEST] @FirstName nvarchar(50), @MiddleName nvarchar(50), @LastName nvarchar(50) AS BEGIN DECLARE @LocalCode nvarchar(10) = 'TEST'; SET NOCOUNT ON; EXEC TIE.LocalCodeRuleOne @FirstName, @MiddleName, @LastName, @LocalCode OUTPUT SELECT @LocalCode END GO TIE.CALLTEST calls this stored proc: ALTER PROCEDURE [TIE].[LocalCodeRule1] @FirstName nvarchar(50), @MiddleName nvarchar(50), @LastName nvarchar(50), @LocalCode nvarchar(10) OUTPUT AS BEGIN SET NOCOUNT ON --Rule 1 -- Take 1st letter of First, middle and last name ----------------------------------------------------- SET @LocalCode = LEFT(@FirstName, 1) IF (@MiddleName is null) BEGIN SET @LocalCode += LEFT(@LastName, 1) END ELSE IF(@MiddleName is not null) BEGIN SET @LocalCode += LEFT(@MiddleName, 1) SET @LocalCode += LEFT(@LastName, 1) END SELECT [LocalCode] = @LocalCode; END but I get this error: Msg 8144, Level 16, State 2, Procedure LocalCodeRuleOne, Line 0 Procedure or function LocalCodeRuleOne has too many arguments specified. What's wrong? I have to pass in the OUTPUT variable but the SP LocalCodeRuleOne wants it to have a value. This is different to the original post that started this thread. I'm confused. Thanks in advance
output
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
mjharper avatar image
mjharper answered
Your EXEC statement calls and stored proc called "TIE.LocalCodeRuleOne". Your ALTER statement is for a stored proc called "[TIE].[LocalCodeRule1]". It sounds like you have two procedures with slightly different names - at a guess TIE.LocalCodeRuleOne doesn't have the same number variables as [TIE].[LocalCodeRule1] and therefore you're getting the "too many arguements" error.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Dugh!!! What an idiot. Thank you.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.