Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

SP help with data type

I have a sql string that I converted into a SP and it doesn`t return the same
records. When I run the SP through VB i get a syntax error converting the
value '%' to a data type integer and when I run the sql string it works.
I have tried different ways and I am stuck. Any help is appreciated.

SP:

(@Location varchar(3),@Year integer, @Month integer,@Code varchar(2))
WHERE Location LIKE @Location + '%'
AND DATEPART(yyyy,Date1) LIKE @Year + '%'
AND DATEPART(m,Date1) LIKE @Month + '%'
AND Code LIKE @Code + '%'

SQL string:

WHERE Location LIKE ''+'%'
AND DATEPART(yyyy,Date1) LIKE ''+'%'
AND DATEPART(m,Date1) LIKE ''+'%'
AND Code LIKE ''+'%'
[862 byte] By [PhilipL] at [2007-11-9 21:08:54]