StoredProc Incorrect syntax when executing another StoredProc

I have an issue where I want to execute a stored procedure within another procedure and pass a Unique Identifier through to that second StoredProc.

The receiving StoredProc is a error reporting procedure that records when an error has occurred for bug fixes requirements. One of those fields is a Decription of the error. I want to pass through, as shown in the code: 'Portal ID passed does not exist: ' + @nPortalUID, but I get the error: Line 23: Incorrect syntax near '+'.

I have also tried to send through just the nPortalUID value but get the response: 'Operand type clash: uniqueidentifier is incompatible with text'.

I have tried converting the data type to nvarchar and text (the receiving fields data type is Text), but nothing seems to be working.
ALTER PROCEDURE [dbo].[FeatureSettings]
	@nFeatureId		int = 0, 
	@nPortalUID		uniqueidentifier = ''
AS
BEGIN
    -- Check for UID and set portal id
	DECLARE @nPortalId int
	SET @nPortalId = ISNULL((SELECT aPortalId FROM System_Portals WHERE nPortalUniqueId = @nPortalUID),0)
 
	-- get features details
	IF @nPortalId <> 0
		BEGIN
			SELECT @nPortalId
		END
	ELSE
		BEGIN
			-- Catch error
			EXEC System_ErrorHandle 'FeatureSettings','StoredProc','Portal ID passed does not exist: '+@nPortalUID,0
		END
	
END

Open in new window

longbloke69Asked:
Who is Participating?
 
reb73Commented:
In the ELSE segment try -

BEGIN
      -- Catch error
      DECLARE @errMsg nvarchar(500)
      SET @errMsg = 'FeatureSettings','StoredProc','Portal ID passed does not exist: '+CAST(@nPortalUID AS nvarchar(50))
      EXEC System_ErrorHandle , @errMsg, 0
END
0
 
Raja Jegan RSQL Server DBA & ArchitectCommented:
You have declared @nPortalId  as int.

DECLARE @nPortalId int

Kindly convert it into Varchar / char and then concat it with your string.
Concating integer with a string will give you this error.
0
 
adatheladCommented:
Hi,

Try converting @nPortalUID to a VARCHAR:

'Portal ID passed does not exist: '+ CAST(@nPortalUID AS VARCHAR(50))
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
adatheladCommented:
Beaten to it :)
0
 
longbloke69Author Commented:
Thanks for the quick response!
0
 
longbloke69Author Commented:
rrjegan17 and adathelad: I have declared@nPortalId as INT because it is an integer coming from the Portals table. You were mixing up @nPortalId with @nPortalUID!


0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.