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
 Transact-SQL (2000)
 Queries in Stored Procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-08-08 : 07:40:35
Nachi writes "I'm calling a stored procedure based on some condition and passing some variables to the stored procedure.

One of the variable will have a value something like this
"EMP_JOIN_DATE in ('date1','date2','date3')"

Using this varaible in stored procdures I have to write a query something like

select @record_count=count(*) from emp where
emp_join_date in (all the dates from that variable)

I tried using replace method and removed the sting EMP_JOIN_DATE in but it works for one values not for multiple dates.

is there any way I can pass all the dates in to this query?"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-08-08 : 13:09:21
You need to double the single quotes.
Also why do you want to pass condition as parameter?
Read this fully
http://www.sommarskog.se/dynamic_sql.html


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -