顯示廣告
隱藏 ✕
看板 Book11
作者 book11 (不可失憶)
標題 複製資料
時間 2011年07月14日 Thu. PM 09:06:57


USE AIMS
GO
DECLARE @dtid
DECLARE @mer_name varchar(255)
DECLARE @mer_edctitle varchar(255)
DECLARE @rsCount int
DECLARE CUR CURSOR
FOR
SELECT dtid FROM repository WHERE dtid
IN (
'29566011','29566012','這裡用xls大法')

OPEN CUR
FETCH NEXT FROM CUR INTO @dtid
WHILE @@FETCH_STATUS = 0 BEGIN
	
SET @rsCount = COUNT(*) FROM repository_history WHERE dtid = @dtid)
	
IF @rsCount = 1
	
BEGIN
	
	
SELECT @dtid=dtid, @mer_name=mer_name, @mer_edctitle=mer_edctitle FROM repository WHERE dtid=@dtid
	
	
UPDATE r SET
	
	
	
r.dtid=@dtid,
	
	
	
r.mer_name=@mer_name,
	
	
	
r.mer_edctitle=@mer_edctitle,
	
	
FROM repository r
	
	
WHERE r.dtid=@dtid
	
ELSE
	
	
--萬一有多筆,處理一下
	
END
	
FETCH NEXT FROM CUR INTO @dtid
END
CLOSE CUR
DEALLOCATE CUR


--
※ 作者: book11 時間: 2011-07-14 21:06:57
※ 看板: Book11 文章推薦值: 0 目前人氣: 0 累積人氣: 118 
r)回覆 e)編輯 d)刪除 M)收藏 ^x)轉錄 同主題: =)首篇 [)上篇 ])下篇