Stored procedure returns nothing

It shouldn't be a problem to find, but after long hours of work I can't seem to notice what I am doing wrong here.

There is a very simple stored procedure:

ALTER PROCEDURE MyProc  
@input char(10)

AS

    BEGIN
        SET NOCOUNT ON;
        SELECT isonum 
        FROM iso where isonum LIKE '%' + @input + '%'
        ORDER BY isonum
    END

      

when executing query: select isonum from iso where isonum like '%2333%'

- I get data, but when executing stored procedure:

exec MyProc '2333'

- I get nothing ???

What's wrong here?

0


source to share


2 answers


Change to @input char(10)

on@input varchar(10)

your sp is currently running



isonum from iso where isonum like '%2333 %'

+2


source


ALTER PROCEDURE MyProc  
@input varchar(10)   --<-- Use varchar here 

AS

    BEGIN
        SET NOCOUNT ON;
        SELECT isonum 
        FROM iso where isonum LIKE '%' + @input + '%'
        ORDER BY isonum
    END

      



'CHAR' or 'NCHAR', and they add white spaces to the passed lines if they are less than the maximum data length.

0


source







All Articles