日期:2014-05-17 浏览次数:20694 次
IF EXISTS(SELECT 1 FROM [CustomerSchedule_Temp] WHERE [ContractNO] = 'F8N37643' AND [BaseData] = '2013-01-21' AND [CompID] = 'KH0001')
BEGIN
DELETE FROM [CustomerSchedule_Temp] WHERE [ContractNO] = 'F8N37643' AND [BaseData] = '2013-01-21' AND [CompID] = 'KH0001'
END
INSERT INTO [CustomerSchedule_Temp]([OTISWeeks], [Remark1], [Remark2], [Dstation], [OrderNumber], [ShippMethod], [ContractNO], [ContractType], [BaseData], [IsWorry], [PlanType], [PlaceOfDelivery], [ReceiveData], [UnderCust], [DeliveryDate], [Batch], [Area], [OWeight], [Ladder], [LadderRemark], [CompID], [RequestFinishDate], [LeaveFacDate], [ReciveDate], [PartsBuyDate], [DrawDownData], [AssemFinishDate], [InventoryFinishDate], [ProcDownData], [WholeBankDate], [SelfFinishDate], [CancelCause], [CompNumber], [ContactVersionsNo], [contract_stat], [DrawFinishData], [HzFSendData], [ID], [IN_Time], [Inbatches], [Input_ImportInfo], [KeyPartyDesc], [ModifyData], [ModifyPrsn], [PickUpType], [RequestData], [UpInventoryDate], [PType], [SendData], [Attachment], [CompType], [PcData], [FirstDeliDate], [BoxNum], [Series], [TrsptModeID]) VALUES(NULL, NULL, NULL, NULL, NULL, NULL, 'F8N37643', '客梯', '2013-01-21', NULL, '410-1', NULL, ISNULL('2013-01-11', CONVERT(VARCHAR(10),GETDATE(),120)), '泉州市XXXX机械有限公司', '2013-01-21', '1', '福州', '1', 'GeN2-MR', 'CMD', 'KH0001', '2013-01-21', '2013-01-21', NULL, '2013-01-16', '2013-01-14', NULL, '2013-01-15', '2013-01-14', '2013-01-17', '2013-01-16', NULL, NULL, NULL, ISNULL(NULL, ('正常')), NULL, NULL, '0000000000000076', ISNULL(NULL, (CONVERT([varchar](20),getdate(),(120)))), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 76, NULL)
USE test
GO
-->生成表tb
if object_id('tb') is not null
drop table tb
Go
Create table tb([Type] nvarchar(1))
Insert into tb
Select N'A'
Union all Select N'B'
INSERT INTO TB
SELECT * FROM OPENROWSET('MICROSOFT.ACE.OLEDB.12.0','EXCEL 12.0;HDR=YES;IMEX=2;DATABASE=H:\test.xls',[Sheet1$]) AS t
WHERE NOT EXISTS(SELECT 1 FROM tb AS x
WHERE x.Type=t.TYPE
)
/*
(4 個資料列受到影響)
*/
SELECT * FROM tb
/*
Type
----
A
B
C
D
E
F
*/