일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
- 파리바게트 청라 SK점
- 최신트래커
- 트래커
- 동적쿼리
- 내장함수
- 재테크
- Google Map
- jquery
- 함수
- C#
- db
- 트레커
- 하남
- .net
- 파리바게트
- 술안주
- 맛집
- 카카오헤어샵
- javascript
- MSsql
- 박근혜 탄핵
- 신장사거리
- Lock
- 국정화 반대
- 하남맛집
- 초대장
- 카카오가 찾아준 헤어샵
- 국정화
- 티스토리
- 토렌트
- Today
- Total
featur
[MSSQL] 계층형 + 페이징 게시판 본문
/**************************************************************************************************/
/**************************************************************************************************/
IF OBJECT_ID('dbo.uspGetGoodsQnaPagingList','P') IS NOT NULL
BEGIN
DROP PROCEDURE dbo.uspGetGoodsQnaPagingList
END
GO
CREATE PROCEDURE dbo.uspGetGoodsQnaPagingList
@oidStoreGroup INT
, @oidStore INT
, @oidGoodsMaster INT
, @oidGoodsDetail INT
, @page INT
, @totalCount INT OUTPUT
--------------WITH ENCRYPTION
AS
/*!
* \brief 제품 Q&A
* \remarks
* \author
* \test
DECLARE @totalCount INT
EXEC uspGetGoodsQnaPagingList 10,100111,497569,2,1,@totalCount OUTPUT
SELECT @totalCount
*/
BEGIN
SET NOCOUNT ON
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
SET LOCK_TIMEOUT 3000
SET XACT_ABORT ON
-- 1:성공, 0: 기본 오류값, 음수:오류코드
-- SET @rv = 0
/**********************************************************************************************
** 작업시작(이하에만기술)
**********************************************************************************************/
DECLARE @pagesize INT = 10
IF ( @page IS NULL OR @page = 0 )
SET @page = 1
SELECT
@totalCount = COUNT(*)
FROM go_goodsQna
WHERE n1Deleted = 0
AND oidStoreGroup = @oidStoreGroup
AND oidStore = @oidStore
AND oidGoodsMaster = @oidGoodsMaster
AND oidGoodsDetail = @oidGoodsDetail
;WITH tree_query AS (
SELECT
oidStoreGroup
, oidStore
, oidQna
, oidFKQna
, oidQna AS sort
, n4Level
, strContent
, oidRegStore
, isPrivate
, n1Deleted
FROM go_goodsQna
WHERE n1Deleted = 0
AND oidStoreGroup = @oidStoreGroup
AND oidStore = @oidStore
AND oidGoodsMaster = @oidGoodsMaster
AND oidGoodsDetail = @oidGoodsDetail
AND n4Level = 0
UNION ALL
SELECT
B.oidStoreGroup
, B.oidStore
, B.oidQna
, B.oidFKQna
, B.oidFKQna AS sort
, B.n4Level
, B.strContent
, B.oidRegStore
, B.isPrivate
, B.n1Deleted
FROM go_goodsQna B
INNER JOIN tree_query C
ON B.oidFKQna = C.oidQna
WHERE B.n1Deleted = 0
AND B.oidStoreGroup = @oidStoreGroup
AND B.oidStore = @oidStore
AND B.oidGoodsMaster = @oidGoodsMaster
AND B.oidGoodsDetail = @oidGoodsDetail
AND B.n4Level > 0
)
, PagingList AS (
SELECT
ROW_NUMBER() OVER ( ORDER BY sort, n4Level ) AS [rownum]
, *
FROM tree_query
)
SELECT * FROM PagingList WHERE rownum BETWEEN ( ( @page - 1 ) * @pagesize ) + 1 AND @page * @pagesize
'개발 > MSSQL' 카테고리의 다른 글
[MSSQL] 테이블명, 컬럼명 검색 (0) | 2017.07.07 |
---|---|
[MSSQL] 산술 오버플로 오류가 발생했습니다. (0) | 2017.04.27 |
[MSSQL] 트랜잭션 로그 백업(Transaction Log Backup) (0) | 2016.12.21 |
[MSSQL] 차등백업, 복구 방법 (0) | 2016.12.21 |
[MSSQL] 전체 백업 (FULL BACKUP) (0) | 2016.12.21 |