일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- update
- tempDB
- JavaScript
- javascript 한글입력체크
- XML
- jdbc driver
- ERD
- asp함수
- instr
- 이미지세로길이
- sql랭킹
- join
- 인젝션
- 자바기초
- FileSystemObject
- sql업데이트
- 이미지가로길이
- 정규식
- injection
- MSSQL보안
- SPLIT
- 한글입력체크
- array
- sql순위
- VARIABLE
- wap
- inner join
- WML
- VarType
- xmldom
- Today
- Total
3초기억력
Cursor 사용 예제 본문
SET NOCOUNT ON
Declare curGet_ViewSO1_PaperLog_Query CURSOR
FOR
select
count(*) as count_all,
convert(varchar(10), regdate, 121) as q_date,
datepart(hh, regdate) as q_time,
isnull(sum(cost),0) as countpay,
mrd
from
SO1_Portal_Log
where
convert(varchar(10),regdate,121) = convert(varchar(10), dateadd(d,-1,getdate()), 121)
and mrd in ('3800', '3802', '480', '4800', '6800', '390', '3806')
and phone not in (select phone_mdn from kocn_phone)
group by mrd, convert(varchar(10), regdate, 121), datepart(hh, regdate)
order by convert(varchar(10), regdate, 121), datepart(hh, regdate)
FOR READ ONLY
OPEN curGet_ViewSO1_PaperLog_Query
Declare @count_all int
, @q_date varchar(20)
, @q_time varchar(20)
, @countpay int
, @mrd varchar(20)
Fetch next From curGet_ViewSO1_PaperLog_Query into @count_all, @q_date, @q_time, @countpay, @mrd
While @@Fetch_status=0
Begin
insert into So1_ALL_Paper_Times_Log (wdate, wtime, cost, cnt, regdate, winc)
values ( replace(@q_date, '-', '') , right('0'+@q_time,2), @countpay, @count_all, getdate(), @mrd)
Fetch next From curGet_ViewSO1_PaperLog_Query into @count_all, @q_date, @q_time, @countpay, @mrd
end
close curGet_ViewSO1_PaperLog_Query
deallocate curGet_ViewSO1_PaperLog_Query
SET NOCOUNT OFF
go
'쿼리_MSSQL' 카테고리의 다른 글
ms-sql UPDATE 문을 제대로 써보자! (0) | 2008.11.13 |
---|---|
MS-SQL 랭킹(순위) 매기기 (0) | 2008.11.13 |
ms-sql 2000 SQL인젝션방지용 쿼리문 (0) | 2008.11.13 |
MS-SQL 2000 보안 쿼리문 (0) | 2008.11.12 |
tempDB 로그 삭제 (0) | 2008.11.12 |