看板 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
回列表(←)
分享