Skip to content
Advertisement

Stored Procedure not working with variables

I have a stored procedure as follows:

When I run the above by passing the search variable as 04029125070527 I get no results.

But if I edit my stored procedure as follows, I get a result. The only difference is in the above I’m trying to send the variable and in the second its hard coded (not what I want to do, just trying to debug).

What am I doing wrong here?

Advertisement

Answer

You need to declare the size of your nvarchar parameter. Without a size declaration, your parameter is declared implicitly as an nvarchar(1).

In addition, your parameter should not be in single quotes.

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement