Click here to Skip to main content
15,916,835 members
Home / Discussions / Database
   

Database

 
GeneralRe: SQL Mail Pin
samoore23-Aug-05 7:32
samoore23-Aug-05 7:32 
GeneralProblem with Update ADO record through VBS Pin
IFriendly23-Aug-05 4:20
IFriendly23-Aug-05 4:20 
GeneralT-SQL Problem Pin
WDI23-Aug-05 2:45
WDI23-Aug-05 2:45 
GeneralRe: T-SQL Problem Pin
Colin Angus Mackay23-Aug-05 3:13
Colin Angus Mackay23-Aug-05 3:13 
GeneralRe: T-SQL Problem Pin
WDI23-Aug-05 4:27
WDI23-Aug-05 4:27 
GeneralRe: T-SQL Problem Pin
Colin Angus Mackay23-Aug-05 4:54
Colin Angus Mackay23-Aug-05 4:54 
GeneralRe: T-SQL Problem Pin
Frank Kerrigan23-Aug-05 4:16
Frank Kerrigan23-Aug-05 4:16 
GeneralFiltering and Paging Pin
WDI23-Aug-05 2:11
WDI23-Aug-05 2:11 
I have a stored procedure to filtering data as :

CREATE PROCEDURE sp_getFilteredAdvertisement
@advertisementTypeID varchar(20),
@visible varchar(2),
@minDate varchar(40),
@maxDate varchar(40)

AS
declare @SQL as nvarchar(1000)

SET @SQL = 'SELECT [Advertisement].[advertisementID] , [Advertisement].[owner] , [Advertisement].[fileName] , [Advertisement].[link] , [Advertisement].[altText] , ABS([Advertisement].[visible]) AS visible , [Advertisement].[viewCounter] , [Advertisement].[clickCounter] , [AdvertisementType].[name] , [Advertisement].[startDate] FROM [Advertisement] INNER JOIN [AdvertisementType] ON [Advertisement].[AdvertisementTypeID]=[AdvertisementType].[AdvertisementTypeID] WHERE 1=1 '

IF ( LEN( @advertisementTypeID ) > 0 )
BEGIN
SET @SQL = @SQL + 'AND [Advertisement].[advertisementTypeID] = ' + @advertisementTypeID
END

IF ( LEN( @visible ) > 0 )
BEGIN
SET @SQL = @SQL + 'AND [visible] = ' + @visible
END

IF ( LEN( @minDate ) > 0 )
BEGIN
SET @SQL = @SQL + 'AND [startDate] >= ''' + @minDate + ''''
END
IF ( LEN( CAST( @maxDate AS VARCHAR(40) ) ) > 0 )
BEGIN
SET @SQL = @SQL + 'AND [startDate] <= ''' + @maxDate + ''''
END
exec (@SQL)

RETURN



I have a stored procedure to paging found from msdn :

CREATE PROCEDURE northwind_OrdersPaged
(
@PageIndex int,
@PageSize int
)
AS
BEGIN
DECLARE @PageLowerBound int
DECLARE @PageUpperBound int
DECLARE @RowsToReturn int

-- First set the rowcount
SET @RowsToReturn = @PageSize * (@PageIndex + 1)
SET ROWCOUNT @RowsToReturn

-- Set the page bounds
SET @PageLowerBound = @PageSize * @PageIndex
SET @PageUpperBound = @PageLowerBound + @PageSize + 1

-- Create a temp table to store the select results
CREATE TABLE #PageIndex
(
IndexId int IDENTITY (1, 1) NOT NULL,
AdvID int
)

-- Insert into the temp table
INSERT INTO #PageIndex (AdvID)
SELECT
advertisementID
FROM
Advertisement
ORDER BY
advertisementID DESC

-- Return total count
SELECT COUNT(advertisementID) FROM Advertisement

----
select into


-- Return paged results
SELECT
O.*
FROM
Advertisement O,
#PageIndex PageIndex
WHERE
O.advertisementID = PageIndex.AdvID AND
PageIndex.IndexID > @PageLowerBound AND
PageIndex.IndexID < @PageUpperBound
ORDER BY
PageIndex.IndexID

END


How i can put paging procedure in filtering procedure ?
GeneralRe: Filtering and Paging Pin
miah alom25-Aug-05 10:40
miah alom25-Aug-05 10:40 
QuestionCannot lock record? Pin
Javolin22-Aug-05 14:30
Javolin22-Aug-05 14:30 
AnswerRe: Cannot lock record? Pin
Christian Graus22-Aug-05 14:33
protectorChristian Graus22-Aug-05 14:33 
Questioninsert text truncated in ADO, not in ODBC? Pin
ir_fuel22-Aug-05 11:06
ir_fuel22-Aug-05 11:06 
AnswerRe: insert text truncated in ADO, not in ODBC? Pin
toxcct22-Aug-05 20:23
toxcct22-Aug-05 20:23 
GeneralRe: insert text truncated in ADO, not in ODBC? Pin
ir_fuel22-Aug-05 22:28
ir_fuel22-Aug-05 22:28 
AnswerRe: insert text truncated in ADO, not in ODBC? Pin
Rob Graham23-Aug-05 2:32
Rob Graham23-Aug-05 2:32 
GeneralAccess tables providing only 65636 rows Pin
softty22-Aug-05 10:07
softty22-Aug-05 10:07 
GeneralRe: Access tables providing only 65636 rows Pin
softty28-Aug-05 7:50
softty28-Aug-05 7:50 
GeneralUPDATE the first n matching records Pin
Luis Alonso Ramos22-Aug-05 5:36
Luis Alonso Ramos22-Aug-05 5:36 
QuestionWhat does .net stand for? Pin
Tuwing.Sabado22-Aug-05 1:40
Tuwing.Sabado22-Aug-05 1:40 
AnswerRe: What does .net stand for? Pin
toxcct22-Aug-05 3:33
toxcct22-Aug-05 3:33 
Generalview Pin
magnifique22-Aug-05 1:12
magnifique22-Aug-05 1:12 
GeneralRe: view Pin
Frank Kerrigan23-Aug-05 0:08
Frank Kerrigan23-Aug-05 0:08 
GeneralRe: view Pin
magnifique23-Aug-05 0:14
magnifique23-Aug-05 0:14 
GeneralRe: view Pin
Frank Kerrigan23-Aug-05 0:37
Frank Kerrigan23-Aug-05 0:37 
GeneralSQL Server Pin
hung_ngole21-Aug-05 18:59
hung_ngole21-Aug-05 18:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.