I have an sql stored procedure like this:
CREATE PROCEDURE [dbo].[usp_Test_ListProcessSQL]
@LocationIDs as varchar(max) =''
AS
BEGIN
IF EXISTS(SELECT dbo.Locations.LocationID FROM dbo.Locations where LocationID in (@LocationIDs))
Return 0
ELSE
Return 1
END
when i run it like this:
usp_Test_ListProcessSQL 2478
it returns 0
but when i run it from VB 6 code, It returns 1
Public Function TestListProcessSQL(lLocationId As String) As Integer
Dim cmd As ADODB.Command, prm As ADODB.Parameter
Set cmd = New ADODB.Command
cmd.ActiveConnection = cn
cmd.CommandType = adCmdStoredProc
cmd.CommandText = "usp_Test_ListProcessSQL_True"
With cmd
.Parameters.Append .CreateParameter("return_value", adInteger, adParamReturnValue)
.Parameters.Append .CreateParameter("@LocationIDs", adBSTR, adParamInput, , lLocationId)
End With
cmd.Execute
TestListProcessSQL = cmd.Parameters("return_value")
End Function
Please suggest why code is returning wrong/different value
IN, if you'd care to search for them.INclause indicate that you're going down the wrong route - you're going to have to restructure your stored procedure anyway to accommodate multiple values, there's not much point spending time fixing it for the one scenario where it may work.