Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
chiman
21 Posts |
Posted - 2007-11-20 : 15:25:51
|
| Hi, I have follwing union query. I want to put this all in a temp table.select Store_Id,batchnumber From Adjustments where updatedDt between '10/30/2007' and '11/20/2007' and Store_id in(8637 ,8641)group by Store_Id, batchnumberUnionselect DestinationId,b.batchNumber frombatch b inner join Carton C on C.Carton_Id = b.General_ID inner join Document d on d.Document_Id = c.Document_Id where b.BatchType = 'Warehouse' and b.TranTable = 'Carton' and (d.DestinationId in (8637 ,8641) ) and c.UpdatedDt Between '10/30/2007' and '11/20/2007' Unionselect d.DestinationId,b.BatchnumberFrombatch b inner join Document d on d.Document_Id = b.General_Id where b.BatchType = 'TransferIn' and b.TranTable = 'Document' and (d.DestinationId in (8637,8641) ) and d.UpdatedDt Between '10/30/2007' and '11/20/2007' Unionselect d.SourceId,b.batchNumber Frombatch b inner join Document d on d.Document_Id = b.General_Id where b.BatchType = 'TransferOut' and b.TranTable = 'Document' and (d.SourceId in (8637,8641) ) and d.UpdatedDt Between '10/30/2007' and '11/20/2007' order by batchnumberKindly advice.ThanksRenu |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-11-20 : 15:28:42
|
| CREATE TABLE #temp (...)INSERT INTO #tempYourQueryGoesHereTara KizerMicrosoft MVP for Windows Server System - SQL Serverhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
chiman
21 Posts |
Posted - 2007-11-20 : 15:51:35
|
| hey thanks a lot..I was trying to do it this way..Select Store_Id, BatchNumber into #temp from <tablename>Union..Thanks again... |
 |
|
|
|
|
|