I need to get a two-part result set into my web page. The two parts have the same fields, but are sorted differently, so a UNION query won't work. Will it be faster to do two statements that INSERT INTO a Temp Table, and then SELECT * the result set (all in a stored procedure), OR issue two separate SELECTS (coming from ASP, that would mean twice the connection-time overhead). OR, is there a third option that would be better?Here's an example of the code that I would use to do the Temp Table solution, if I were running against the Northwind database:CREATE TABLE #TempList ( RID int IDENTITY (1,1), EmpID int NOT NULL, FName varchar(10) NOT NULL, LName varchar(20) NOT NULL, HDate datetime NULL )INSERT INTO #TempList (EmpID, FName, LName, HDate)SELECT EmployeeID, FirstName, LastName, HireDateFROM Employees WHERE HireDate < '1/1/94'ORDER BY LastName, FirstNameINSERT INTO #TempList (EmpID, FName, LName, HDate)SELECT EmployeeID, FirstName, LastName, HireDateFROM Employees WHERE HireDate >= '1/1/94'ORDER BY HireDateSELECT * FROM #TempList
Other details... NT 4 Server, SQL 7, Expected Result Set < 100 rows total, may grow to 500 rows, actual Source Table has < 5000 rows, WHERE Clause will really be based on an inline formula.This is my first production-level voyage into Temp Tables... Anything I'm overlooking?TIA,Mark Caldwell