Create Procedure In Sql Server Using UNION
EXAMPLE :
SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================CREATE PROCEDURE [dbo].[getiklan] @PageIndex INT = 1 ,@PageSize INT = 10 ,@RecordCount INT OUTPUTASBEGIN SET NOCOUNT ON; SELECT ROW_NUMBER() OVER ( ORDER BY [idiklan] ASC )AS RowNumber ,[idiklan],[judul],[idkategori],[nmkategori],[status],[harga],[deskripsi],[image1],[tglposting],[UserId],[position] INTO #Results FROM [tblother] UNION ALL SELECT ROW_NUMBER() OVER ( ORDER BY [idiklan] ASC )AS RowNumber ,[idiklan],[judul],[idkategori],[nmkategori],[status],[harga],[deskripsi],[image1],[tglposting],[UserId],[position] FROM [tblproperti]
SELECT @RecordCount = COUNT(*) FROM #Results SELECT * FROM #Results WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1 DROP TABLE #ResultsEND
THIS EXAMPLE WORKING MY HOME.
0 KOMENTAR