Re: Passing comma seperated values to a stored proc
From: Keith Kratochvil (sqlguy.back2u_at_comcast.net)
Date: 12/22/04
- Next message: Arthur Dent: "Re: SQL Server, Table Joins and Plus notation"
- Previous message: CJM: "Re: Select * where 1 = 1"
- In reply to: M Smith: "Passing comma seperated values to a stored proc"
- Next in thread: M Smith: "Re: Passing comma seperated values to a stored proc"
- Reply: M Smith: "Re: Passing comma seperated values to a stored proc"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 22 Dec 2004 10:41:05 -0600
Here is an excellent article:
http://www.sommarskog.se/dynamic_sql.html#List
-- Keith "M Smith" <msmith@avma.org> wrote in message news:OIWACTE6EHA.2592@TK2MSFTNGP09.phx.gbl... > I have an application where the user will type in ID numbers into a single > field in an ASP page. They can type in multiple IDs if they are seperated > by a comma. I want to pass this string into a Stored Proc and just use an > "in" command in the where clause to return a recordset back to the ASP page. > The problem is that the ID numbers are integer and the parameter is a > varchar. When I try to pass multiple IDs into the Stored Proc I get an > error. > Here is the Stored Proc > CREATE PROCEDURE test @pvID as varchar(500) AS > Select * from member_t where member_ID in (@pvID) > GO > When I try it by typing - exec test '123456,123457,123458' - I get this > error > "Syntax error converting the varchar value '123456,123457,123458' to a > column of data type int." > > How would I go about converting the string to an integer and still use the > In statement. > Thanks > > > >
- Next message: Arthur Dent: "Re: SQL Server, Table Joins and Plus notation"
- Previous message: CJM: "Re: Select * where 1 = 1"
- In reply to: M Smith: "Passing comma seperated values to a stored proc"
- Next in thread: M Smith: "Re: Passing comma seperated values to a stored proc"
- Reply: M Smith: "Re: Passing comma seperated values to a stored proc"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|