Create Procedure In Sql Server With UNION and SLUG
Example :USE [dbbisnis]GO/****** Object: StoredProcedure [dbo].[getiklan] Script Date: 03/05/2016 13:54:00 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGO-- =============================================ALTER PROCEDURE [dbo].[getiklan] @PageIndex INT = 1 ,@PageSize INT = 10 ,@RecordCount INT OUTPUTASBEGIN SET NOCOUNT ON; SELECT ROW_NUMBER() OVER ( ORDER BY [idiklan] DESC )AS RowNumber ,[idiklan],[judul],[idkategori],[nmkategori],[status],[harga],[deskripsi],[image1],[tglposting],[UserId],[position],REPLACE([judul],' ','-')[SLUG] 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],REPLACE([judul],' ','-')[SLUG] 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 Code Working In My Computer
0 KOMENTAR