![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 |
#3
| |||
| |||
|
|
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 |
#4
| |||
| |||
|
|
Here is an excellent article: http://www.sommarskog.se/dynamic_sql.html#List -- Keith "M Smith" <msmith (AT) avma (DOT) org> wrote in message news:OIWACTE6EHA.2592 (AT) TK2MSFTNGP09 (DOT) 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 |
#5
| |||
| |||
|
|
Great article. It really helped a lot. Thank You. Mike "Keith Kratochvil" <sqlguy.back2u (AT) comcast (DOT) net> wrote in message news:uCqWcVE6EHA.936 (AT) TK2MSFTNGP12 (DOT) phx.gbl... Here is an excellent article: http://www.sommarskog.se/dynamic_sql.html#List -- Keith "M Smith" <msmith (AT) avma (DOT) org> wrote in message news:OIWACTE6EHA.2592 (AT) TK2MSFTNGP09 (DOT) 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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |