Results 1 to 7 of 7

Thread: [RESOLVED] URGENT please help in imporving this code performace

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Posts
    150

    [RESOLVED] URGENT please help in imporving this code performace

    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:
    1. CREATE PROCEDURE Report  @ListStr varchar(1000) AS
    2.  
    3. Declare @ListTbl Table  (STID int)
    4. Declare @CP int
    5. Declare @SV int
    6.  
    7. While @ListStr<>''
    8. Begin
    9.     Set @CP=CharIndex(',',@ListStr)
    10.     If @CP<>0
    11.     Begin
    12.         Set @SV=Cast(Left(@ListStr,@CP-1) as int)
    13.         Set @ListStr=Right(@ListStr,Len(@ListStr)-@CP)
    14.     End
    15.     Else
    16.     Begin
    17.         Set @SV=Cast(@ListStr as int)
    18.         Set @ListStr=''
    19.     End
    20.     Insert into @ListTbl Values (@SV)
    21. End
    22. select id, field1,field2, field3 from projecttable
    23. Where   ID  in (Select STID From @ListTbl)

    I appreciate any help.
    Last edited by waely; Nov 8th, 2006 at 01:52 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width