To display the banners in sequential manner
I want to display the banners in a sequential manner instead of displaying it randomly.Say for eg if there are 3 records then it should display 1st then 2nd and then 3rd. Following is the stored procedure which displays the banner randomly.But I want it in sequential manner.
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[sp_RandomBanner]
as
Declare @rows int
Declare @nRandNum int
create table #TempTable
(
dtPostDate datetime,
vchrLinkURL varchar(100),
vchrImagePath varchar(100),
vchrImageName varchar(50),
vchrStatus varchar(50),
vchrChangeStatus varchar(50),
intBannerID int identity(1,1)
)
INSERT INTO #TempTable
Select dtPostDate, vchrLinkURL, vchrImagePath,vchrImageName,vchrStatus,vchrChangeS tatus From tblBanner where vchrStatus='Running'
select @rows=count(*) from #TempTable
select @nRandNum=Round(((@rows - 1) * Rand() + 1), 0)
select * from #TempTable where intBannerID=@nRandNum and vchrStatus='Running'
Regards,
Jijish
|