hi,
I have stored procedure that expects project IDs. I created a temp table for the IDs then pace in my where clause.
if I test my sql statement whithout my where clause ( without the ID's) then it takes 1 second to execute but if I include the where clause it takes 20 sec which causes my application to time out. please keep in mind that the number of project ids will keep increasing with time but for now I have about 50.
VB Code:
CREATE PROCEDURE Report @ListStr varchar(1000) AS Declare @ListTbl Table (STID int) Declare @CP int Declare @SV int While @ListStr<>'' Begin Set @CP=CharIndex(',',@ListStr) If @CP<>0 Begin Set @SV=Cast(Left(@ListStr,@CP-1) as int) Set @ListStr=Right(@ListStr,Len(@ListStr)-@CP) End Else Begin Set @SV=Cast(@ListStr as int) Set @ListStr='' End Insert into @ListTbl Values (@SV) End select id, field1,field2, field3 from projecttable Where ID in (Select STID From @ListTbl)
I appreciate any help.




Reply With Quote