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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using varable with IN clause for an integer field

Status
Not open for further replies.

rturner003

Programmer
Nov 20, 2001
21
GB
create procedure p_test

@cs varchar(200)

as

update decisions
set subscription_date=getdate()
where id in (@cs)

The parameter cs would contain someting like '81,82,85'
The field id is an int field

I tried charindex which of course does not work as id is an int. Is their a better way than using set @sql='.... in ('+@cs+')' and EXEC(@sql)?
 
Just did some like that:

CREATE procedure procDEMO03(@cs varchar(200))
as
begin
EXEC ('SELECT * FROM tableDemo01 WHERE id in '+ @cs)
end

GO
EXEC DEMO03 '(1,2,3,4)'

and it works fine. I don't know it this examples helps. if it doesn't please let me know
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top