July 26, 2011 at 11:50 pm
Hi All Experts,
I am having one stored procedure which is written by third part and i can't able to make single character change in it. it returns 2 recordset - recordset 1 and recordset 2. By any way it is possible through SQL coding so it return only 2nd recordset (using that SP as input or any way). I dont want 1st recordset. In addition to that i dont want to use SSIS/ASP.NET .... I just want using pure T-SQL statments , Stored procedures...
Is this possible ? waiting for solution
Thanks
July 27, 2011 at 2:09 am
if we have the code then it will be easy to comment.
But as of now, I think one value if you dont want then you can make it to return default which you can define.
----------
Ashish
July 27, 2011 at 2:29 am
Here's an easy way but it depends upon the structure and content of the two result sets:
-- Make a test proc returning 2 result sets
CREATE PROCEDURE dbo.junk AS
SELECT SetID = 1, today = GETDATE() UNION ALL SELECT 1, GETDATE()+(1/24.00)
SELECT SetID = 2, today = GETDATE() UNION ALL SELECT 2, GETDATE()+(1/24.00)
RETURN 0
go
-- Test it
EXEC dbo.junk
GO
-- Pick one of the result sets
DROP TABLE #MyTable
CREATE TABLE #MyTable (SetID INT, today DATETIME)
INSERT INTO #MyTable (SetID, today) EXEC dbo.junk
SELECT * FROM #MyTable WHERE SetID = 2
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 27, 2011 at 3:52 am
Hi Chris,
Thanks for your reply.
but the problem is types and number of columns are not common in both recordset.
Thanks
Manoj
July 27, 2011 at 4:36 am
Sorry, but Chris's solution is probably the best solution you will get without posting the code that's causing you this heartache. We need to see the problem in order to understand it and get you the best possible solution.
July 27, 2011 at 5:10 am
Thanks for the help.
I am explaining my prob:
create eproc test_2ndrec
as
begin
select name from test_N1 where id = 2 -- returns single row single column
select * from test3 -- returns 5 rows with 10 columns
end
now i want to use second recordset and dont want 1st recordset or you can say i want to hide 1st recordset. procedure modification is also not possible (becuase 3rd party procedure).
hope now you can understand my proble clearly
Thanks
Manoj
July 27, 2011 at 5:38 am
Does "name" in the first result come close to being the same datatype of any of the columns in the second result set?
July 27, 2011 at 5:54 am
Yes Definitely. it is of nvarchar() and is there in 2nd resultset too.
July 27, 2011 at 6:13 am
Then take Chris's code and adjust it. Expand the temp table's column list, making sure the Name column is the first one, then do the insert as he says. Make sure the columns are nullable.
See if that works for you (it may not, but it's worth a shot).
July 27, 2011 at 6:21 am
Thanks for stepping up Brandie 🙂
I tried it with a 2-column and 3-column output. Since the result sets are both run into the same table, you get a column mismatch error. I don't think there's a way round this in TSQL other than making minor changes to the sproc.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply