Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

STRUGGLING with a Stored Procedure Parameter Issue 1

Status
Not open for further replies.

checkai

Programmer
Jan 17, 2003
1,629
US
Here's what I have....

a SP that takes 4 variables...one being a description field which could have apostrophe's in it....another being a string that looks like this
@list = '34,434,343'

my sp uses the code where wipID in (@list)

however wipID is an int...the list is actually an array in .NET that gets converted to a string...

I get a cannot convert to type INT error....

Any suggestions would be amazing...

DLC
 
Hi,

Use dynamic SQL to do this.. Have a look at FAQ3132

Declare @SQL Varchar(7000)
Declare @InList varchar(200)
SET @InList = '34,43,343,34'

SET @SQL = 'SELECT * from TBL where wipID IN (' + @InList + ')'

exec (@SQL)

As for Apostrophe in a field, replace it with 2 single quotes. for eg:


Declare @w varchar(200)

set @w = 'Brain''s'

print @w

This will print Brian's in QA window.

Sunil
 
As long as your not using wipID in any mathematical expressions, couldn't you just convert wipID to a string after its value has been established, and then use it in the IN expression against @list?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top