/****** Script for SelectTopNRows command from SSMS ******/
SELECT * FROM [LFBMP.Operating].[dbo].[ShoppingOrder]
--更新ShoppingOrder
-- update [LFBMP.Operating].[dbo].[ShoppingOrder] set ContainerTypeID=t1.ContainerTypeID,[ContainerTypeStr]=t1.[ContainerTypeStr] From [LFBMP.Operating].[dbo].[BusinessOrder] as t1,[LFBMP.Operating].[dbo].[ShoppingOrder] as t2 where t1.B_ID=t2.B_ID

--更新bookingOrder
--update [LFBMP.Operating].[dbo].[BookingOrder] set state=t3.state From [LFBMP.Operating].[dbo].[BusinessOrder] as t1 ,[LFBMP.Operating].[dbo].[BookingOrder] as t2 ,[LFBMP.Operating].[dbo].[BookingScheme] as t3 where t2.BS_ID=t3.BS_ID and t1.B_ID=t3.B_ID

UPDATE Table1 AS t1
SET (Field1,Field2) = (SELECT Field21, Field22
FROM Table2 t2
INNER JOIN Table3 t3
ON t3.Field31 = t2.Field23
INNER JOIN Table4 t4
ON t3.Field32 = t4.Filed41
WHERE t2.Field24 >= ''
AND t1.fId = t4.fId);

SELECT
[B_ID],[CommissionCompanyID],[ShippingOrderNo],[ShipperID]
,(SELECT [C_DisplayFormat] FROM [LFBMP.CRM].[dbo].[CRM.Company] Where [C_ID]=[ShipperID]) as [Shipper]
,[ConsigneeID]
,(SELECT [C_DisplayFormat] FROM [LFBMP.CRM].[dbo].[CRM.Company] Where [C_ID]=[ConsigneeID]) as [Consignee]
,[NotifyID]
,(SELECT [C_DisplayFormat] FROM [LFBMP.CRM].[dbo].[CRM.Company] Where [C_ID]=[NotifyID]) as [Notify]
,[PortOfLoadingID],[PortOfSransshipmentID],[PortOfDischargeID],[FinalDestinationID],[CommissioItemStr],[HBPaymentTerm],[HBPaymentTermPlace],[ContainerTypeID],[ContainerTypeStr],[CarrierID],[ClaimETD],[HBLoadingTermID],[Adder]
FROM [LFBMP.Operating].[dbo].[BusinessOrder]

04-18 01:46