日期:2014-05-17 浏览次数:20630 次
--说明:TempTable这个表,自己先创建一下
--Insert into #ee (PO,ShipDate,Color,Sizx,Qty,ProcessID,CuttingQty,Qtyx) 这好几个语句可以合成一个,想办法
--不要用游标,试着去SQL实现
--总之,这个存储过程写的非常不好。
ALTER Procedure [dbo].[ShipDateQtyPush_CuttingQty] @PO varchar(12), @ShipDate varchar(10)
as
declare @sql varchar(8000)
if exists (select * from tempdb.dbo.sysobjects where name='#bb' ) drop table #bb
if exists (select * from tempdb.dbo.sysobjects where name='##cc' ) drop table ##cc
if exists (select * from tempdb.dbo.sysobjects where name='##dd' ) drop table ##dd
if exists (select * from tempdb.dbo.sysobjects where name='#gg' ) drop table #gg
--
Create Table #ProcessQty
(
id [int] identity (1,1) not null, --10
PO [varchar] (20),
Color [varchar] (50),
Sizx [varchar] (20),
Qty int,
ProcessID [varchar] (3)
)
DECLARE @begin DATETIME
SET @begin = GETDATE()
Insert into #ProcessQty (PO,ProcessID,Color,Sizx,Qty)
select
Left(jo_master.cust_so_ref,CharIndex('-',jo_master.cust_so_ref)-1) PONO,[fg_rfid]..rfid_transaction_table.major,