I have a stored procedure that looks like this:
DECLARE @A TABLE ( TabYear int, Std decimal(18,2))
DECLARE @B TABLE ( TabYear int, Std decimal(18,2))
BEGIN
DECLARE @FinalTable TABLE (TabYear int, HoldayA decimal(18,2), HolidayB decimal(18,2))
BEGIN
INSERT INTO @A(TabYear, std)
Select ... from ...
INSERT INTO @B(TabYear, Std)
Select ... from ...
END
INSERT INTO @FinalTable(TabYear, HoldayA, HoldayB)
SELECT
A.TabYear, a.Std, U.Std
FROM
@A A
LEFT JOIN
@B U ON a.TabYear = U.TabYear
END
Select * from @FinalTable
Now I want to get that into a DATASET within my .NET application using the TableAdapter Wizard. I choose :"Use existing stored procedure" and choose the procedure (above) but as Data Column I get only Column1. It looks like the DataTableAdapter does not recognize the table. If I let the SP run on the server everything is fine. I get the table as I wish. I also checked if the wizard recognizes other SP's I am working with on the table and that works fine. But I have to admit that all the other SP's I use are straigth Select commands nothing with querying @Tables like in this SP. Could anyone help me get the table into my application. I do not have go go with the DataSet necessarily a code solution getting the data into an array or something would help me too.
It looks like the DataTableAdapter does not recognize the table.simple, use actual DB calls and functions, NOT a wizard. Also looking at your procedure, that can be cleaned up a bit. I see some issues having a good execution plan and performance issues. For one: both table's (@A, @B) should have an identity column and they dont.