Tuesday, 28 August 2018

Stored procedure does not return anything

It is should be no problem to find but after long hours at my job I cannot notice what I'm doing wrong here.

There is 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 a query: select isonum from iso where isonum like '%2333%' - I get the data,but when executing the stored procedure:
exec MyProc '2333' - I get nothing???
What's wrong here?

Change to @input char(10) to @input varchar(10)
your sp is currently running
isonum from iso where isonum like '%2333 %'

0 comments:

Post a Comment