首页 > 数据库技术 > 详细

SQL中的循环

时间:2014-06-03 12:59:44      阅读:374      评论:0      收藏:0      [点我收藏+]

DECLARE @SOInfoList TABLE
(
SONumber INT,
SODate datetime,
Status char(1)
)
INSERT INTO @SOInfoList
(
SONumber,
SODate,
Status
)
SELECT T.c.value(‘(SONumber/text())[1]‘, ‘int‘) AS SONumber
,T.c.value(‘(SODate/text())[1]‘, ‘nvarchar(50)‘) AS SODate
,T.c.value(‘(Status1/text())[1]‘, ‘char(1)‘) AS Status
FROM
@RealTimeSOList.nodes(‘/ArrayOfLoadDataMasterBuffer/LoadDataMasterBuffer‘) T (c)

UPDATE S
SET SODate = T.SODate,
Status1 = T.Status,
LastEditUser =‘SO‘,
LastEditDate = GETDATE()
FROM newegg.dbo.NESO_RealTimeSO_ProcessLog S
INNER JOIN @SOInfoList T
ON S.SONumber = T.SONumber

INSERT INTO newegg.dbo.NESO_RealTimeSO_ProcessLog
(
SONumber,
Sodate,
Status1,
InUser,
LastEditUser,
LastEditDate
)
SELECT SONumber,SODate,[Status],‘SO‘,‘SO‘,GETDATE() from @SOInfoList
WHERE SONumber NOT IN(SELECT SONumber FROM newegg.dbo.NESO_RealTimeSO_ProcessLog WITH(NOLOCK))

SQL中的循环,布布扣,bubuko.com

SQL中的循环

原文:http://www.cnblogs.com/Wolfmanlq/p/3759847.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!