>if object_id("tepmdb..#Results',N'U') IS NOT NULL drop table #Results; > > select ... > into #Results > from .... > > > select R.*, Rt.... > from #Results R inner join dbo.Routes Rt on ... > >Thanks, I've tried that but when I select this SP as the source for the tableadapter I do not get any columns. This is my full definition:
USE [IBC] GO /****** Object: StoredProcedure [dbo].[InvoicesSelectByManifestNumberTest] Script Date: 01/29/2013 10:31:23 ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [dbo].[InvoicesSelectByManifestNumberTest2] ( @awb_manifestnumber int ) AS SET NOCOUNT ON; if object_id('tepmdb..#Results',N'U') IS NOT NULL drop table #Results; SELECT cus_firstname ,cus_lastname ,cus_company ,cus_addr1 ,cus_addr2 ,cus_number ,cus_hold ,cus_cashonly ,inv_pk ,inv_number ,inv_date ,inv_pieces ,inv_weight ,inv_goodsvalue ,awb_number ,awb_manifestdate ,awb_manifestnumber ,rte_name ,are_name ,cnt_code into #Results FROM Customers inner join Routes on cus_rtefk = rte_pk INNER JOIN Areas ON cus_arefk = are_pk INNER JOIN Countries ON cus_cntfk = cnt_pk INNER JOIN Invoices ON cus_PK = Invoices.inv_cusfk INNER JOIN AirWayBills ON inv_awbfk = awb_pk WHERE ([awb_manifestnumber] = @awb_manifestnumber) SELECT cus_firstname ,cus_lastname ,cus_company ,cus_addr1 ,cus_addr2 ,cus_number ,cus_hold ,cus_cashonly ,inv_number ,inv_date ,inv_pieces ,inv_weight ,inv_goodsvalue ,awb_number ,awb_manifestdate ,awb_manifestnumber ,rte_name ,are_name ,cnt_code ,ivd_amount ,cty_name FROM #Temp INNER JOIN InvoiceDetails ON inv_pk = ivd_invfk INNER JOIN ChargeTypes ON ivd_ctyfk = cty_pk ORDER BY rte_name ,are_name ,cus_number ,inv_number ,cty_name GOAm I doing something wrong?