I need help getting this to work. Hope I have explained the scope well enough.I have an asp application that that connects to a sp on SQL Server 2005 that again calls a sp on SQL Server 2000 (using linked server) to select production data. I use a SqlDataAdapter to fill a DataSet and consequently a GridView. Existing SP code on Sequel Server 2005:CREATE PROCEDURE sp_Vecellio_ProductionQtyCompare @JobNumber intasexec [VGIWPW03-SQL3\EQUENTIALPROD].goLabor30.dbo.sp_Vecellio_ProductionInquiry @JobNumber GO
Result will return a Cost Code and QuantityNote: This procedure I need to expand with an additional select from a db2 table (cost qty table on an AS400). The objective is to compare production date vs accounting data. The select element is @JobNumber for both tables. I'm not sure if need to use a temp table. There could be entries in either table that may not exists in the other.Existing SP code on Sequel Server 2000:CREATE PROCEDURE sp_Vecellio_ProductionInquiry @JobNumber intasSELECT distinct(dbo.Item.CompanyItemId), substring(dbo.Item.Name, 1, 15) as description, case dbo.SourceType.CompanySourceTypeId when 'PR' then SUM(dbo.ProductionEvent.Quantity) end AS Ttl_Qty FROM dbo.Batch INNER JOIN dbo.Event ON dbo.Batch.BatchGuid = dbo.Event.BatchGuid INNER JOIN dbo.Job ON dbo.Event.JobGuid = dbo.Job.JobGuid INNER JOIN dbo.ProductionEvent ON dbo.Event.EventGuid = dbo.ProductionEvent.EventGuid INNER JOIN dbo.Item ON dbo.Event.ItemGuid = dbo.Item.ItemGuid INNER JOIN dbo.Source ON dbo.ProductionEvent.SourceGuid = dbo.Source.SourceGuid INNER JOIN dbo.SourceType ON dbo.Source.SourceTypeGuid = dbo.SourceType.SourceTypeGuid LEFT OUTER JOIN dbo.Product ON dbo.ProductionEvent.ProductGuid = dbo.Product.ProductGuid left outer join dbo.JobNoteEvent on Event.EventGuid = dbo.JobNoteEvent.EventGuidWHERE dbo.job.CompanyJobId = @JobNumber and dbo.SourceType.CompanySourceTypeId = 'PR'GROUP BY dbo.Item.CompanyItemId, dbo.SourceType.CompanySourceTypeId, dbo.Item.NameGO
SP code that will call procedure on the db2/400 (should be part of "sp_Vecellio_ProductionQtyCompare" declare @JobNumber char(12)Set @JobNumber =' 1100281' Exec ('Call QGPL.get_jobqty(?)', @JobNumber) AT AS400SRV_MSDASQLSP code on db2/AS400 (that will return cost code and qty)create procedure get_jobqty (in @JobNumber varchar(12)) result set 1 language sql reads sql data begin declare c1 scroll cursor with return for select gbsub, DECIMAL(SUM(gban01 + gban02 + gban03 + gban04 + gban05 + gban06 + gban07 + gban08 + gban09 + gban10 + gban11 + gban12 + gban13 + gban14)/FLOAT(100.00),38,2) as sum_qty from vgiprddta/f0902lc where gbmcu = @JobNumber and gblt = 'AU' GROUP BY gbsub; open c1; set result sets cursor c1; end;