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)
 Stored Proc Problem

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-08-15 : 09:09:45
Deepak writes "Hi,

I am having a stored Proc as

RepSummary to which i pass a parameter

@vchCategoryId varchar(100), in this parm i pass id's seperated
by comma like -

RepSummary '12,13,14'

Now within the SP I use this value to filter query with IN
clause -

SELECT * FROM SALE WHERE CATEGORYID IN(@vchCategoryId)

however it gives following err -

Server: Msg 245, Level 16, State 1, Procedure RepSummary , Line 6
Syntax error converting the varchar value '12,13,14' to a column of data type int.

pls guide on how to use param to be used in IN clause

thanks
deepak"

JustinBigelow
SQL Gigolo

1157 Posts

Posted - 2002-08-15 : 11:45:40
Dynmic SQL to the rescue...

[url]http://www.sqlteam.com/item.asp?ItemID=4619[/url]

hth,
Justin

Have you hugged your SQL Server today?
Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-08-15 : 14:45:16
or...

select
<col_list>
from
sale
where
charindex(isnull(convert(varchar,categoryid)+',',''),@vchcategoryid+',')

 


Jay White
{0}
Go to Top of Page
   

- Advertisement -