富贵资源网 Design By www.hznty.com
复制代码 代码如下:
INSERT INTO #DirtyOldWIPBOM SELECT TOP (100) PERCENT dbo.WIP_BOM.Model, dbo.WIP_BOM.PartNumber,WIP_BOM.WIP
FROM dbo.WIP_BOM left OUTER JOIN dbo.BOM_CHINA ON LTRIM(dbo.WIP_BOM.Model) = LTRIM(dbo.BOM_CHINA.Model) AND LTRIM(dbo.WIP_BOM.PartNumber) = LTRIM(dbo.BOM_CHINA.PartNumber) AND dbo.WIP_BOM.Qty = dbo.BOM_CHINA.Qty AND BOM_CHINA.WIP=
WIP_BOM.WIP WHERE (dbo.BOM_CHINA.Model IS NULL) AND EXISTS(SELECT * FROM dbo.BOM_CHINA WHERE WIP = WIP_BOM.WIP AND LTRIM(Model) = LTRIM(WIP_BOM.Model))
这样就可以成功。
复制代码 代码如下:
但SELECT TOP (100) PERCENT dbo.WIP_BOM.Model, dbo.WIP_BOM.PartNumber,WIP_BOM.WIP into #DirtyOldWIPBOM
FROM dbo.WIP_BOM left OUTER JOIN dbo.BOM_CHINA ON LTRIM(dbo.WIP_BOM.Model) = LTRIM(dbo.BOM_CHINA.Model) AND LTRIM(dbo.WIP_BOM.PartNumber) = LTRIM(dbo.BOM_CHINA.PartNumber) AND dbo.WIP_BOM.Qty = dbo.BOM_CHINA.Qty AND BOM_CHINA.WIP=
WIP_BOM.WIP WHERE (dbo.BOM_CHINA.Model IS NULL) AND EXISTS(SELECT * FROM dbo.BOM_CHINA WHERE WIP = WIP_BOM.WIP AND LTRIM(Model) = LTRIM(WIP_BOM.Model))
会提示error "There is already an object named '#DirtyOldWIPBOM' in the database"
为什么?
[笔记]:千万不要用游标,用临时表和表变量代替游标会极大的提高性能,今天用游标处理700行数据用了2小时,用临时表不到1秒就搞定。
INSERT INTO #DirtyOldWIPBOM SELECT TOP (100) PERCENT dbo.WIP_BOM.Model, dbo.WIP_BOM.PartNumber,WIP_BOM.WIP
FROM dbo.WIP_BOM left OUTER JOIN dbo.BOM_CHINA ON LTRIM(dbo.WIP_BOM.Model) = LTRIM(dbo.BOM_CHINA.Model) AND LTRIM(dbo.WIP_BOM.PartNumber) = LTRIM(dbo.BOM_CHINA.PartNumber) AND dbo.WIP_BOM.Qty = dbo.BOM_CHINA.Qty AND BOM_CHINA.WIP=
WIP_BOM.WIP WHERE (dbo.BOM_CHINA.Model IS NULL) AND EXISTS(SELECT * FROM dbo.BOM_CHINA WHERE WIP = WIP_BOM.WIP AND LTRIM(Model) = LTRIM(WIP_BOM.Model))
这样就可以成功。
复制代码 代码如下:
但SELECT TOP (100) PERCENT dbo.WIP_BOM.Model, dbo.WIP_BOM.PartNumber,WIP_BOM.WIP into #DirtyOldWIPBOM
FROM dbo.WIP_BOM left OUTER JOIN dbo.BOM_CHINA ON LTRIM(dbo.WIP_BOM.Model) = LTRIM(dbo.BOM_CHINA.Model) AND LTRIM(dbo.WIP_BOM.PartNumber) = LTRIM(dbo.BOM_CHINA.PartNumber) AND dbo.WIP_BOM.Qty = dbo.BOM_CHINA.Qty AND BOM_CHINA.WIP=
WIP_BOM.WIP WHERE (dbo.BOM_CHINA.Model IS NULL) AND EXISTS(SELECT * FROM dbo.BOM_CHINA WHERE WIP = WIP_BOM.WIP AND LTRIM(Model) = LTRIM(WIP_BOM.Model))
会提示error "There is already an object named '#DirtyOldWIPBOM' in the database"
为什么?
[笔记]:千万不要用游标,用临时表和表变量代替游标会极大的提高性能,今天用游标处理700行数据用了2小时,用临时表不到1秒就搞定。
富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com
暂无评论...