임시테이블 & 레코드수 채우기

set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go



--------------------------------------------------------



CREATE PROC [dbo].[up_main_update]

AS
SET NOCOUNT ON

declare @totalcount int, @chk_num int

CREATE TABLE #Notice(
[idx] [int] IDENTITY(1,1) NOT NULL,
[Gubun] [nvarchar] (10) NULL,
[seq] [int] NULL,
[Title] [nvarchar](50) COLLATE Korean_Wansung_CI_AS NULL,
[RegDate] [nvarchar] (10) NULL

)



insert into #Notice select gubun, seq, title, regdate from
(
select top 3 'notice' as 'gubun', seq,title,right(replace(convert(varchar(10),regdate,111),'/','.'),8) as 'regdate'
from notice where seq in (select top 5 seq from notice where status = '1' and len(title) > 0 order by rank desc,seq desc )
union
select top 2 'event' as 'gubun', seq,title,right(replace(convert(varchar(10),regdate,111),'/','.'),8) as 'regdate'
from event where seq in (select top 5 seq from event where status = '1' and len(title) > 0 order by seq desc )
) as a order by regdate desc

set @totalcount = @@rowcount
set @chk_num = 0
while(@totalcount < 5)
begin
if(@chk_num = 0 and @totalcount = 0 )
begin
--insert into #Notice select 'notice' as 'gubun', '0','등록된 자료가 없습니다.',right(replace(convert(varchar(10),getdate(),111),'/','.'),8) as 'regdate'
insert into #Notice select 'notice' as 'gubun', '0','undefined', 'undefined' as 'regdate'
end
else
begin
-- insert into #Notice select 'notice' as 'gubun', '0','undefined',right(replace(convert(varchar(10),getdate(),111),'/','.'),8) as 'regdate'
insert into #Notice select 'notice' as 'gubun', '0','undefined', 'undefined' as 'regdate'
end

print @totalcount

set @totalcount = @totalcount + 1
set @chk_num = @chk_num + 1
end




select * from #Notice order by idx

drop table #Notice

--------------------------------------------------------
크리에이티브 커먼즈 라이센스
Creative Commons License
이올린에 북마크하기

Posted by 홍반장

2007/08/01 17:25 2007/08/01 17:25
Response
No Trackback , No Comment
RSS :
http://tcbs17.cafe24.com/tc/rss/response/2578

Trackback URL : http://tcbs17.cafe24.com/tc/trackback/2578

« Previous : 1 : ... 574 : 575 : 576 : 577 : 578 : 579 : 580 : 581 : 582 : ... 1009 : Next »

블로그 이미지

- 홍반장

Archives

Recent Trackbacks

Calendar

«   2024/11   »
          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
Statistics Graph

Site Stats

Total hits:
242941
Today:
68
Yesterday:
1403