码迷,mamicode.com
首页 > 数据库 > 详细

SQL中的循环

时间:2014-06-03 13:02:04      阅读:295      评论:0      收藏:0      [点我收藏+]

标签:des   c   a   ext   int   get   

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中的循环

标签:des   c   a   ext   int   get   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!