1:往現有的表中增加一個欄位 IF NOT EXISTS ( SELECT 1 FROM sys.sysobjects so WITH ( NOLOCK ) INNER JOIN sys.syscolumns sc WITH ( NOLOCK ) ON so.id = sc.id WHERE so. ...
1:往現有的表中增加一個欄位
IF NOT EXISTS ( SELECT 1
FROM sys.sysobjects so WITH ( NOLOCK )
INNER JOIN sys.syscolumns sc WITH ( NOLOCK ) ON so.id = sc.id
WHERE so.name = 'EgPurchase_OrderPlan'
AND sc.name = 'IsNewSystem' )
BEGIN
ALTER TABLE dbo.EgPurchase_OrderPlan ADD IsNewSystem INT NOT NULL DEFAULT 0
EXECUTE sp_addextendedproperty N'MS_Description', '是否推送新系統', N'user',
N'dbo', N'table', N'EgPurchase_OrderPlan', N'column', N'IsNewSystem'
END
GO
2:更新一個欄位
UPDATE dbo.EgSys_ExportSet
SET ColumnNames='訂單編號|1,店鋪名稱|1,倉庫名稱|1,平臺|1,商品|1,商品名稱|1,商品編號|1,規格編碼|1,顏色名稱|1,規格名稱|1,商品數量|1,弔牌價|1,單價|1,成本價|1,成交價|1,應付金額|1,實付金額|1,優惠|1,運費|1,重量|1,交易單號|1,實付物流費用|1,快遞單號|1,物流公司|1,買家昵稱|1,收件人|1,國家|1,省|1,市|1,區|1,地址|1,完整地址|1,郵編|1,買家留言|1,賣家留言|1,買家手機|1,買家電話|1,買家郵箱|1,訂單狀態|1,訂單付款時間|1,訂單完結時間|1,發貨日期|1,換貨狀態|1,換貨數量|1,付款狀態|1,刪除狀態|1,副單狀態|1,退款狀態|1,退款金額|1,主訂單號|1,城市代碼|0,訂單備註|0,分銷商名|0,業務員|0,國家中文|0,國家簡寫|0,申報費用|0,商品類別|0,商品類別(英)|0,商品備註|0,客戶條形碼|1,Sku狀態|0,商品條形碼|1'
WHERE ModuleMark='AllOrder'
3:查詢EDL轉運單號
SELECT d.*
FROM dbo.EgSys_Delivery d WITH ( NOLOCK )
INNER JOIN dbo.Egsys_PlatformTrade t WITH ( NOLOCK ) ON t.tid = d.tid
WHERE d.deliveryTime < CONVERT(DATE, GETDATE())
AND d.deliveryTime >= CONVERT(DATE, DATEADD(DAY, -70000, GETDATE()))
AND t.orderState >= 4
AND t.order_deleteState != 1
AND d.logisticsCompany LIKE 'EdlExpress%'
AND d.logisticsNo LIKE 'HMZX%'