Hi every one
this is My datalist pagination store prosedure
USE [behtop]
GO
/****** Object: StoredProcedure [dbo].[GetCustomersPageWise2] Script Date: 06/11/2012 17:56:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[GetCustomersPageWise2]
@H_name nvarchar(50)
,@PageIndex INT = 1
,@PageSize INT = 5
,@RecordCount INT OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SELECT ROW_NUMBER() OVER
(
ORDER BY House_p.[Date] desc
)AS RowNumber
,House_Info.Image_Behcode,House_Info.Image_Header,House_Info.Name,substring(House_Info.[Service1]+'-'+House_Info.[Service2]+'-'+House_Info.[Service3]+'-'+House_Info.[Service4]+'-'+House_Info.[Service5]+'-'+House_Info.[Service6],0,46)+'...'as Description,SUBSTRING(House_Info.[Address],0,26)+'...' as Address,MAX(House_p.[Date]) as [Maxdate]
INTO #Results
from House_Info
Inner Join House_p ON House_Info.Behcode = House_p.Behcode
where House_Info.H_name=@H_name
group by House_Info.address,House_Info.Name,House_Info.Image_Behcode,House_Info.Image_Header,House_Info.Service1,House_Info.Service2,House_Info.Service3,House_Info.Service4,House_Info.Service5,House_Info.Service6 ,House_Info.Description,House_p.[Date]
SELECT @RecordCount = COUNT(*)
FROM #Results
SELECT * FROM #Results
WHERE (RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1)
DROP TABLE #Results
END
I want set DISTICT to select item but I don't Know where can i add it in this SP?
I want add this code to this SP
select distinct top 5 House_Info.Image_Behcode,House_Info.Image_Header,House_Info.Name ,SUBSTRING(House_Info.[Address],0,26)+'...' as Address
how i can do it?
thanks
declare @House_p table(Id int, Behcode varchar(50), ProductName varchar(50), date datetime ,H_name varchar(20))
insert into @House_p
select 1, '1111', 'Iron', '2012-04-04 13:34:14.000,'Electric''
union all
select 2, '1111', 'Vacuum Cleaner', '2012-03-04 14:44:14.000,'Electric''
union all
select 3, '2222', 'Sofa', '2012-02-04 15:54:14.000','Cloth'
union all
select 2, '2222', 'Scarf', '2012-04-18 12:34:14.000','Cloth'
union all
select 5, '2222', 'Shirt', '2012-04-12 09:34:14.000','Cloth'
declare @House_Info table(Id int, Behcode varchar(50), Name varchar(50), address varchar(30),description varchar(50),H_name varchar(20))
insert into @House_Info
select 1, '1111','sara','paris','test','Electric'
union all
select 2, '2222', 'jack', 'italy','test2','Cloth'
union all
select 3, '3333', 'Jennifer', 'france','test3','Furniture'
union all
select 2, '4444', 'Micheal', 'italy',test4','Computer'
union all
select 5, '5555', 'paul', 'germany''test5'.'state'