Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Multiple Integer Query

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2001-07-10 : 22:04:30
Steve writes "I am attempting to write a stored procedure with the following query:

DECLARE @Str varchar(1000)
SET @Str = '5, 18, 103, 222'
SELECT *
FROM Company
WHERE CompanyID IN (@Str)

CompanyID is a Primary Key of type Int. I am getting the following error:

"Syntax error converting the varchar value '5, 18, 103, 222' to a column of data type int."

My goal is to pass multiple integers as a single parameter into the stored procedure and use those integers to query a type int column. Is there a way to accomplish my goal without getting the above error?

Thanks!
Steve"
   

- Advertisement -