I don't understand the point of creating the temp table, AT ALL.
You don't say how you are *using* this SQL, but if it is part of ANY kind of conventional web site/web page (ASP, ASP.NET, PHP, JSP), that temp table will be WIPED OUT each and every time the web page is sent to the browser, because ALL these technologies only keep the connection open so long as the page is being rendered and then close it once the HTML is sent to the browser. And closing the connect DELETES the temp table!
Tell us what technology you are using for your web page: ASP, ASP.NET, PHP, JSP, CF, or what???
Incidentally, your code for picking one random banner is HORRIBLY over-complicated for SQL Server.
You could accomplish the same thing with no need of the useless temp table:
Code:
CREATE procedure [dbo].[sp_RandomBanner]
AS
Select TOP 1 dtPostDate, vchrLinkURL, vchrImagePath, vchrImageName,
vchrStatus,vchrChangeStatus
FROM tblBanner
WHERE vchrStatus='Running'
ORDER BY NEWID( )
Anyway, as GBianchi asked, do you want the banners to be sequential *PER USER* or sequential for *ALL* users???
And a *VERY* important question, that could make all this a lot simpler and a lot faster: How many banners are there??? [If there are only a few--say less than 100?--you could just put them into memory and forget using the DB and get much better efficiency. Especially easy to do with ASP and ASP.NET, which I'm guessing is what this is for, since you are using SQL Server.]