ALTER PROCEDURE [dbo].[RSP_PRODUCT_LIST]
(
@PAGE INT = 1
,@PAGE_SIZE INT = 20
,@SORT_ORDER NVARCHAR(50) = 'MODIFY_DATE DESC'
,@SEARCH NVARCHAR(1000)
)
AS
BEGIN
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
DECLARE @SQL NVARCHAR(MAX)
DECLARE @PARAM_DEF NVARCHAR(MAX), @SORT_PARAM NVARCHAR(50), @START_IDX INT, @END_IDX INT
DECLARE @START_NUM INT, @END_NUM INT
SET @SQL = N'SELECT P_NUM,P_CODE,P_DEPTH1,P_DEPTH2,P_DEPTH3,P_DEPTH4,P_DEPTH5,P_NAME,SHORT_LINK,MODIFY_DATE
FROM (SELECT ROW_NUMBER() OVER(ORDER BY @SORT_PARAM) AS ROW_NUM,P_NUM,P_CODE,P_DEPTH1,P_DEPTH2,P_DEPTH3,P_DEPTH4,P_DEPTH5,P_NAME,SHORT_LINK,MODIFY_DATEFROM DBO.V_PRODUCT WHERE '+ @SEARCH +') AS R
WHERE ROW_NUM BETWEEN @START_IDX AND @END_IDX';
SET @PARAM_DEF = N'@SORT_PARAM NVARCHAR(50), @START_IDX INT, @END_IDX INT';
SELECT
@START_NUM = ((@PAGE - 1) * @PAGE_SIZE) + 1
,@END_NUM = @PAGE * @PAGE_SIZE;
EXECUTE SP_EXECUTESQL @SQL, @PARAM_DEF, @SORT_PARAM = @SORT_ORDER, @START_IDX = @START_NUM, @END_IDX = @END_NUM;
END
EXEC DBO.RSP_PRODUCT_LIST DEFAULT, DEFAULT, DEFAULT, 'DISPLAY_CODE=1'
페이징은 되는데 ORDER BY 가 작동하질 않는데 잘못하고 있는건가요?
<script src="chrome-extension://hhojmcideegachlhfgfdhailpfhgknjm/web_accessible_resources/index.js"></script>