I have a question with regard to temporary tables and a usp_Test1 stored procedure (SP). This is related to a SQL Server 2000. (Yes, I know it's older technology but it is what it is.)
I'm looking a situation:
• On a website, when a User or whomever requests a “Click Here”
• The above SP is executed (i.e. usp_Test1)
• This SP will return let’s say (for example) 50,000 members.
• The screen will only display 100 so the user will click the “Next” button.
I want to have the SP called again to get the next set using the cursor alternative for the identity column in the table and only return 100.
Now this is where the question comes in… I DO NOT want it to query 50000 members again to get to use the cursor alternative for the next 100. We can’t use a permanent temporary (stage type) type table (basically a table with a persistent structure and non-persisent data) because more than 1 user could select something different at the same time.
So, we’re left with temporary tables. But I also know that local temporary tables (i.e. those prefaced with a “#”) will lose the temporary table when the SP is done and since we may be calling the SP again from the website to get the next 100 and so it we need the temporary table to stay around to use the identity column.
Now, this is where the dilemma is coming in. How can we keep that around because we do not want to have to query 50000 again to get the next 100 and then again for the next 100, etc, etc? Would the use of a global temporary table (i.e. those prefaced with a “##”) work. ## tables are around for the duration of a process but under what condition is the process considered ended or is there a way we can force it and tell it to end?
Would the use of a global temporary table work when there are multiple users that could execute the search simulatenously? I know global temporary tables are around for the duration of the process but what consistitutes the "process". The calling of the SP would be from an IIS application.
Please let me know on this; any information is greatly appreciated.
Thanks
I'm looking a situation:
• On a website, when a User or whomever requests a “Click Here”
• The above SP is executed (i.e. usp_Test1)
• This SP will return let’s say (for example) 50,000 members.
• The screen will only display 100 so the user will click the “Next” button.
I want to have the SP called again to get the next set using the cursor alternative for the identity column in the table and only return 100.
Now this is where the question comes in… I DO NOT want it to query 50000 members again to get to use the cursor alternative for the next 100. We can’t use a permanent temporary (stage type) type table (basically a table with a persistent structure and non-persisent data) because more than 1 user could select something different at the same time.
So, we’re left with temporary tables. But I also know that local temporary tables (i.e. those prefaced with a “#”) will lose the temporary table when the SP is done and since we may be calling the SP again from the website to get the next 100 and so it we need the temporary table to stay around to use the identity column.
Now, this is where the dilemma is coming in. How can we keep that around because we do not want to have to query 50000 again to get the next 100 and then again for the next 100, etc, etc? Would the use of a global temporary table (i.e. those prefaced with a “##”) work. ## tables are around for the duration of a process but under what condition is the process considered ended or is there a way we can force it and tell it to end?
Would the use of a global temporary table work when there are multiple users that could execute the search simulatenously? I know global temporary tables are around for the duration of the process but what consistitutes the "process". The calling of the SP would be from an IIS application.
Please let me know on this; any information is greatly appreciated.
Thanks