rocky_498 (9/20/2012)
Once again thanks and i understand what you saying, Here is the PROBLEM.I can't convert or paste my store procedure here (8 Pages S.P) lot of logic involve....
If i run this query
Select DISTINCT Sid from MDB
where ADate = dateadd(day,datediff(day,1,GETDATE()),0)
AND SID NOT IN (SELECT SID FROM MRequest )
and i get SID > 0
THEN run this S.P
EXEC [INSERT_SP] @sid
When you are saying you do NOT need Cursor, Ok. Could you please tell me what else should i use to
accomplish this task. I know cursor is dam slow if i get more SID in my first query.
I know i have to provide Sample data/Sample code with insert statment and everything, but in this case
i am sorry i am not providing all information that you need.
I suggested a couple of ideas in my last post but it sounds like neither of those are an option. I don't know how long 8 pages is but it sounds like it is a bit complicated. I am guessing this is a lot more than just an insert into a single table. It must be adding data all over the place. Changing that proc to receive a table parameter might help but I don't know your system and how much impact that would make. There are ways around this but it takes a lot more understanding of the tables and such than I have. If changing that proc is not an option then you are probably stuck with a **cough**cursor**cough**.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/