-
Добрый день. Подскажите, будьте добры,как поместить во временную таблицу результат запроса? select top (100000)a.log_DateTime ,a.log_UserID ,a.log_TransactionTypeID ,a.log_OrderShipmentID ,c.loc_Code ,a.log_TaskCode ,e.per_LastName ,e.per_FirstName ,f.Lsc_SSCC ,sum(floor(h.lsp_Quantity))
--,i.prd_PrimaryCode ,f.lsc_UnitID ,x.unt_Code ,isnull(v.shp_Code,x.unt_code) from LV_Log a join LV_LogStock b with (nolock)on b.lsk_LogID=a.log_ID and b.lsk_OriginalLED=0 join LV_Location c with (nolock)on c.loc_ID=b.lsk_LocationID --and c.loc_Code not like'%IN%' join LV_Users d with (nolock)on d.usr_ID=a.log_UserID join COM_Person e with (nolock)on e.per_ID=d.usr_PersonID join LV_LogStockContainer f with (nolock)on f.Lsc_ID=b.lsk_FromContainerID join LV_LogStockPackType h with (nolock)on h.lsp_LogStockID=b.lsk_ID full join LV_Task g with (nolock)on g.tsk_SSCC=f.Lsc_SSCC join LV_Product i with (nolock)on i.prd_ID=b.lsk_ProductID join LV_ItemUnit k on k.itu_ID=h.lsp_ItemUnitID join LV_Unit x on x.unt_ID=k.itu_UnitID and unt_Code = 'BOX1' full join LV_OrderShipment z on z.ost_ID=a.log_OrderShipmentID full join LV_Shipment v on v.shp_ID=z.ost_ShipmentID where a.log_DateTime>'2016-02-05 04:08:53.840' and f.Lsc_SSCC='3026884' --and c.loc_Code='Lr-25-11' group by a.log_DateTime ,a.log_UserID ,a.log_TransactionTypeID ,a.log_OrderShipmentID ,c.loc_Code ,a.log_TaskCode ,e.per_LastName ,e.per_FirstName ,f.Lsc_SSCC --,i.prd_PrimaryCode ,f.lsc_UnitID ,x.unt_Code ,v.shp_Code order by log_TransactionTypeID desc
-
использовать оператор insert
-
можно и select into
-
select * into #TT --создаст from T
insert into #TT -- должна уже быть select * from T ----------
select * into #TT from T where 1=0
чистая #TT, нужного типа столбцы для дальнейшей работы можно навешать индексы
insert into #TT select * from T
в #TT все лежит очень хорошо для дальнейших манипуляций
-
Удалено модератором
|