#2
mywisdom882020-05-08 08:52
|
在SQL介面上搜寻到的指令 :
SELECT ROW_NUMBER() OVER (ORDER BY A.ProjectNo) AS RowNo,A.ProjectNo,A.ProjectName,A.CateMainID,A.CateSubID,A.CreatorNo,C.ItemName,C.CreatorNo,D.ItemNo FROM [tblProject] AS A
INNER JOIN [tblBasCategory] AS B ON A.CateMainID = B.CateMainID AND A.CateSubID = B.CateSubID and A.ReleaseDate IS NULL
INNER JOIN [tblProjectItem] AS C ON A.ProjectNo = C.ProjectNo
INNER JOIN [tblProjectDevpHistory] AS D ON A.ProjectNo = D.ProjectNo and C.ItemNo = D.ItemNo
WHERE D.DHDate >= '2020-04-01' AND D.DHDate <= '2020-05-07' And A.ProjectNo < 'S2020' Group by A.ProjectNo,A.ProjectName,A.CateMainID,A.CateSubID,A.CreatorNo,C.ItemName,C.CreatorNo,D.ItemNo
搜到共数十笔纪录,该如何将这些纪录,只更换新的ProjectNo,循环插入两个资料表(tblProject,tblProjectItem)内?