Multiple Result Sets

Jul 31, 2007

Hi,

I am aware that SSRS does not support stored procedures with multiple data sets, but what if the same stored procedure may only return one set based on a parameter?

For example, lets say if parameter @TableID = 0, the stored procedure returns 2 result sets. But if @TableID = 1, or @TableID = 2, the SP only brings back 1 result set. Is this also not supported?

When I try to do this it still only brings back the fields from the first table. Am I doing something wrong?

Thanks for any insight.

View 2 Replies


ADVERTISEMENT

Multiple Result Sets

Jul 20, 2005

Hi!Another silly question:If a stored procedure returns multiple result sets, how do I choose the oneI want to insert into a table?For example sp_spaceused returns two result sets if object name is ommited.I only need the first result set. How do I do that?Tnx!Darko

View 2 Replies View Related

Multiple Active Result Sets

Mar 29, 2007

Hi,
do u know
has sql server 2000 support MARS?

View 6 Replies View Related

Save Multiple Result Sets To One File??

Aug 9, 2007

Hello,

Is it possible to save the results of several SP calls in a script, to one file?

Here's what I mean:
I want to run these 4 sp calls--
exec EPC_SP1 'aph','live'
exec EAUI_SP2 'noble','newswire'
exec EAUI_SP3 'noble',1
exec EAUI_SP4 5507,'live'

And save the results of each one of those calls to the same file, in other words, an APPEND

Is this or something like it possible in TSQL?

Help appreciated!

Thank you,
--PhB

View 3 Replies View Related

Multiple Result Sets From A Stored Procedure

Sep 28, 2006

I have a stored procedure like the following. This returns 2 result sets, however i only want it to return 2nd (SELECT SomeField FROM SomeTable). How is this done? Note - it is not possible to change 'SomeSPThatReturnsAnIntAndAResultSet '



CREATE PROCEDURE [dbo].[SomeSP]

@SomeParam int

AS

BEGIN

SET NOCOUNT ON;

declare @SomeScalar int

exec @SomeScalar = SomeSPThatReturnsAnIntAndAResultSet @SomeParam

if @SomeScalar = 0

BEGIN

SELECT SomeField FROM SomeTable

END

END

View 6 Replies View Related

How Stored Procedures Return Multiple Result Sets?

Jan 28, 2007

hi

i read that stored procedures can return multiple result sets?how is that?

thanks in advance.

View 4 Replies View Related

Syntax For Returning And Accessing Multiple Result Sets In MSSQL 2k

Dec 29, 2006

Seasons greetings to everyone,A simple question. Could someone show me the syntax to produce multiple (2 or 3) result sets in a stored proc and how you access those sets from a c# program (ASP.NET)..Couldn't find a reference on Google, maybe I was asking the wrong question! Thanks for any help regardsDavej 

View 3 Replies View Related

How To Handle Multiple Result Sets Return From Stored Procedure

Aug 22, 2007

Hi all,

I want to know how to handle multiple result sets return from Stored Procedure? I know one way is to insert the result sets into the table, but the limitation is the result sets must have the same data structure. If the result sets have different data structure, how can I handle it.

Thanks,

View 5 Replies View Related

Return 2 Result Sets

Feb 29, 2008

Hi, I'm trying to return 2 different result sets using the below query mapped to 2 different variables in my execute sql task. I've tried this with one task and 2 seperate tasks but can't get it to work. Is this possible using only one task? It keeps giving me a result set error.


SELECT COUNT(*) AS DeceasedCount
FROM AMGR_User_Fields_Tbl
WHERE (Client_Id = '' or Client_Id is NULL) and Type_Id = 53

SELECT COUNT(*) AS LostCount
FROM AMGR_User_Fields_Tbl
WHERE (Client_Id = '' or Client_Id is NULL) and Type_Id = 469

View 5 Replies View Related

Paged Result Sets

Aug 28, 2006

What is the recommended mechanism for selecting paged results from SQL.

Presently I pass various params including the request Max Items Per Page and the requested page.

The I execute the query as a count with the search params.

Then comes the paging logic, which validates the page number against the request page and number of hits etc.

Then a temp table and record variables are created for the results.

Then I run the query again with a cursor and select the appropriate Items into the temp table based on the paging values (First Item and Last Item).

Then I return the temp table & some additional return params with the Total Hits etc.

The Stored procedure is accessed via an ADO.Net client and the system.data.IDBReader populates a .Net strongly typed collection and is for read only display.

Thanks for any input,

Martin.

View 11 Replies View Related

Two Result Sets From Stored Procedure..

Jun 12, 2008

My stored procedure displays two result sets. How can i use that result sets in my 3-tier application. I want to bind first resultset to repeater control and second to label control. I am using SqlDataReader...

View 6 Replies View Related

How To Rank An Union Of Two Result Sets?

Mar 1, 2007

I am new to SQL Server Integration Services. I need to help here.

If there is only one result set, I could get rank info by putting DENSE_RANK expression inside of my select. My case is that I have two data source. After union of them, I need rank the result set and save result set plus rank info into the destination. I tried to use Derived Column component by using expression DENSE_RANK() over ( order by columnName ). But it does not like it.

Does anyone know how to achieve this?

Thanks!

View 3 Replies View Related

How Come The Result Sets Do Not Match? Why No Error?

Feb 21, 2008

Scenario: Launch SQL Server 2005 Management Studio & Connect to Server, ie: ServerNameInstanceName. Click "New Query" Button

Running the following SQL Statement returns 842 rows but should return 1343:

SELECT A.id, C.PName, B.School
FROM users AS A
LEFT OUTER JOIN Bio AS B ON A.id = B.id
LEFT OUTER JOIN Groups AS C ON A.PName = C.PName ORDER BY A.Id

I get 1343 rows when I change Line 2 of SQL Statement to: "FROM dbName.dbo.users AS A".

Clicking "New Query" w/out first opening the database must run the query in the context of the Master Database??
I noticed in Sql Server 2000 if I connect Query Analyzer to the Server and run the query I get 842 & I can see that the default selected database is master. When I make the change mentioned above I then get 1343.

Why doesn't this produce an error though? I'd rather get an error than the wrong result set.

View 4 Replies View Related

Limiting Rows Returned By Result Sets

May 20, 2008

In MySQL we use "SELECT (....) LIMIT 0, 10" to only return the first 0 to 10 records. Alternatively we could do "LIMIT 10, 20" to return the 10th to 20th records.

What's the equivilent of this in SQL Server?

Thanks

View 4 Replies View Related

SQL 2012 :: Tool To Compare Result Sets

Jun 11, 2014

I am looking for a tool to compare the result sets.

Is there any free tool or Microsoft built in tool that we can use to compare the result sets. Suppose if I change one thing in code and needs to test the am I getting the same result set or not? Instead of doing manually is there any way to compare both result set.

View 5 Replies View Related

SQL 2012 :: Requery Result Sets In SSIS

Feb 10, 2015

I 've got the below RESULT SET after several JOINs & deriving columns from different sources

STUD_ID, ANNUAL_YEAR, COURSES_ID, SUBJECTS_OPTED, CHAPTERS, YEAR_JOINED, Course_Tenure, Sub_ID, SUB_MARKS, EXAM_ID, ATTEMPT_YEAR, ATTEMPT_NO and many more.

Now, I've only one result set available in my DATA FLOW. And I want the below few,

1) STUD_RESULTS:TABLE : Evaluate COURSE-Annual year completion:
Have columns Students, Annual_yr, Results (IF ANY SUB _MARKS are below 35? 'PASS': 'Fail') and few more.
<--I've got to group the result set on STUD_ID and ANNUAL_YEAR.

2) STUD_COURSE_PERF: TABLE: for course performance.
I've got to group the result set on STUD_ID,ANNUAL_YEAR, Course_ID and the other essential

3) STUD_SUB_PREF: TABLE: Evaluating Subjects difficulty
I've got to group the result on STUD_ID,ANNUAL_YEAR, Course_ID, SUBJECTS_OPTED and other essentail.

How to use the only result set to carry on different evaluations?I Applied Multicast on the only result set.

View 1 Replies View Related

Transact SQL :: Get 2 Different Result Sets With GetDate Function

Aug 4, 2015

Periodically throughout the day a report is manually pulled from a SQL Server database.  Is their a way w/o me adding a field to the database to have the result set return the "new" results?  For example, lets say this is our DDL

Create Table OneTwoThree
(
id int
,date11 datetime
,firefly varchar(10)
)

Insert Into OneTwoThree Values (1, '08/03/2015 18:43:32.012', 'Hi'), (2, '08/03/2015 18:44:11.011', 'No'),
(3, '08/03/2015 19:36:33.011', 'Second'), (4, '08/03/2015 19:37:33.011', 'Alpha')

Prior I could use this syntax, but that was only with needing to generate 1 result set.  

Select id, convert(varchar(10), date11, 101) As [Date], firefly from onetwothree
where CONVERT(varchar(10), date11, 101) < CONVERT(varchar(10), GetDate(), 101)

Looking at my datetime values, let's say the 1st was generated at 18:45, obviously the 1st two records in the table would be returned. And let's say a 2nd time I need to generate I want to exclude the 1st two entries as they have already been verified. How can I do such w/o adding a field to the table?

View 11 Replies View Related

Load Result Sets From Mysqldatareader Into Datatable Or Dataset

Nov 8, 2007

hi all.....
i select some records from my database using mysqldatareader.......but i want to load it's result sets into my datatable or dataset....
is it possible and how can i do it this way ?
thanks

View 1 Replies View Related

Can You Caputure And Export Out Result Sets In Temp Tables???

Jan 8, 2001

I need to export out the data in a result set from temp tables. It is in a rather large Dts Stream. Thanks for your help. Brett

View 1 Replies View Related

Naming The Result Sets Returned By Stored Procedure

Jul 6, 2004

Greetings

I have a SQL Server stored procedure that performs several queries and therefore returns several "result sets" at any one time.

Wiring it up via ADO.NET I populate a DataSet with a number of items in the Tables collection - which is great - and I can give each item a name for identification purposes once the DataSet is populated.

But I'd like to know if there is some way I can set the names of each result set *within the text of the stored procedure*, i.e. before the DataSet gets populated.

Any help greatly appreciated.
Stuart

View 14 Replies View Related

How To Suppress Result Sets Returned From A Stored Procedure?

Aug 28, 2006

I have a novice question. How does one suppress result sets returned from a stored procedure?

I have created a procedure which makes use of multiple stored procedures . The purpose of this procedure (lets call it procA), is to count the rows returned from other procedures. The €œOther€? procedures will return rows having an unknown number of columns. I would like to limit any changes which may be needed to be made to the €œOther€? procs.

Once procA has collected all of the information (@@rowcount) from the inner procedures, then it will return a result set having several columns €“ mainly the subProcedure name and number of rows returned.

The purpose of procA is to query several subsystems and identify which ones need attention.

Cursor While Loop
exec @ProcName @ObjectName,@userID,@syncDate
set @recs = @@rowcount;


My c# program calls the sp as follows:

cmd = DataUtility.GetSQLCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "FetchAdminData";
cmd.Parameters.AddWithValue("@userID", userAlias);
cmd.Parameters.AddWithValue("@adminDate",userDate);
reader = cmd.ExecuteReader();

I do not wish to iterate over each resultSet when I am only interested in the last one. Any suggestions?



View 2 Replies View Related

Package Hanging On OLE DB Command With Large Result Sets

Jul 13, 2007

I have an SSIS package (SQL 2005 SP2 and Visual Studio SP1) that does the following:



OLE DB Source --> Conditional Split --> OLE DB Command #1 --> OLE DB Command #2



The source reads from database A. Each row is variable-width and up to several KB wide, including two ntext columns.



Command #1 executes a stored proc in db A, using a bunch of inputs and two output parameters.



Cmd #2 executes an update in db B, using the two output params from cmd #1 as inputs.



When the rowset size is small, around 500, everything works fine.



However, when the rowset size is larger, around 5000, SSIS hangs when trying to execute cmd #2. The profiler shows that none of the cmd #2 updates are ever executed. No error messages are produced, and the connection never times out -- it just hangs forever.



If I replace the cmd #2 updates with a simple select, everything works fine. If I replace it with a stored proc that does an update, it hangs.



The work-around I came up with was to create a new table in db B, and do inserts into the table, but unless I'm missing something, this still seems like a bug...

View 1 Replies View Related

Data Binding To A Stored Procedure That Returns Two Result Sets

Mar 6, 2007

Hi there everyone.  I have a stored procedure called “PagingTableâ€? that I use for performing searches and specifying how many results to show per ‘page’ and which page I want to see.  This allows me to do my paging on the server-side (the database tier) and only the results that actually get shown on the webpage fly across from my database server to my web server.  The code might look something like this:
 
strSQL = "EXECUTE PagingTable " & _
"@ItemsPerPage = 10, " & _
"@CurrentPage = " & CStr(intCurrentPage) & ", " & _
"@TableName = 'Products', " & _
"@UniqueColumn = 'ItemNumber', " & _
"@Columns = 'ItemNumber, Description, ListPrice, QtyOnHand', " & _
"@WhereClause = '" & strSQLWhere & "'"
 
The problem is the stored procedure actually returns two result sets.  The first result set contains information regarding the total number of results founds, the number of pages and the current page.  The second result set contains the data to be shown (the columns specified).  In ‘classic’ ASP I did this like this.
 
'Open the recordset
rsItems.Open strSQL, conn, 0, 1
 
'Get the values required for drawing the paging table
intCurrentPage = rsItems.Fields("CurrentPage").Value
intTotalPages = rsItems.Fields("TotalPages").Value
intTotalRows = rsItems.Fields("TotalRows").Value
 
'Advance to the next recordset
Set rsItems = rsItems.NextRecordset
 
I am trying to do this now in ASP.NET 2.0 using the datasource control and the repeater control.  Any idea how I can accomplish two things:
 
A) Bind the repeater control to the second resultset
B) Build a “pager� of some sort using the values from the first resultset

View 3 Replies View Related

Integration Services :: SSIS - Database Query Result Sets Not Right

Jun 10, 2015

I have a general question I need a few pointers or explanations.  I have a top level Data Flow query in a SSIS package that has been running for years for which I have made some minor changes to pull additional fields and rectify a filter condition. 

I have noticed that when I run this same query, exactly as entered in the Data Flow task, in the SQL Server 2012 Management Studio, the query returns some 105,000+ records but when run in development by executing the package the top level task only indicates some 21,000 records returned.  Since there was not other transformations or filtering performed, I had expected the same record count and am not getting it. 

View 5 Replies View Related

Strange Problem Sql 2005 Returning Different Size Result Sets From Different Machine..

Nov 5, 2007

Hi,

I have a very strange problem using SQL Server 2005

I have several machines running an application, the problem is that on all machines except one of them the size of the result set that gets returned when I execute the following query is dfferent:

Select * from custoemr where EmployeeID = 3

on three out of the four machine the size of the result set is 1000, where on the other machine the size of the result set is 250, No errors are generated..

Can someome please teel me how to preceed in resolving this issue..

thanks,

View 2 Replies View Related

SQL Server 2012 :: Asynchronous Cursor Population Slow For Large Result Sets

Jul 2, 2015

so async cursor population is supposed to create the cursor and return the cursor id quickly, while the server works on async populating the results. For a keyset-driven cursor, SQL Server stores the key sets in tempdb, which it then uses to fetch data for cursor results. Anyway, this works fine for smaller tables, but I'm finding for large result sets, the async cursor population is very slow and indeed seems to approximate synchronous time. The wait stat I get while it is running (supposedly asynchronously) is TRANSACTION_MUTEX.

Example:
--enable async cursor
exec dbo.sp_configure 'cursor threshold', 0; reconfigure;
declare @cursor int, @stmt nvarchar(max), @scrollopt int, @ccopt int, @rowcount int;
--example of giant result set
set @stmt = 'select * from sys.all_objects o1, sys.all_objects o1';

[code]...

Note that using the SQL "select * from sys.all_objects o1" is much faster than "select * from sys.all_objects o1, sys.all_objects o2". However, if cursor population is async, I'd expect the time to return a cursor id to be similar between the two.

View 7 Replies View Related

Problem In Executing Stored Procedure With Temp Table Returns Result Sets

Mar 23, 2006

Hi,
we are facing problem in executing a stored procedure from Java Session Bean,

coding is below.

pst = con.prepareStatement("EXEC testProcedure ?", ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);
pst.setString(1, "IN");
//
rs = pst.executeQuery();
rs.last();
System.out.println(" Row Number "+rs.getRow());
rs.beforeFirst();
while(rs.next())
{
System.out.println(" Procedure is "+rs.getString(1));
}

same sp working perfectly with SQL Server 2000

am getting a error message

com.microsoft.sqlserver.jdbc.SQLServer
Exception: A server cursor cannot be opened on the given statement or statements
. Use a default result set or client cursor.



If a SP doesnt have a temp table, then there is no issue, SP executes perfectly, but if a SP has a temp table, this error occurs.

SP :

create proc testProcedure
@countrCode varchar(3)
as

select countryname INTO #TMPCOU from country where countryCode = @countrCode
SELECT COUNTRYNAME FROM #TMPCOU

Its really very urgent. Please help me...!

Rgds,

Venkatesh.

View 2 Replies View Related

Moving Through Recordset With Multiple Sets

Mar 28, 2008

I'm having some problems dealing with a VB script which delivers multiple results back from SQL Server. The script opens a connection to SQL 2000 and executes a procedure. The stored procedure has five select statements for its result. I receive a recordset object and try to move through each resultset. I get the first two result sets but when I execute the rs.nextrecordset on the third result, the rs.EOF is set to true and I never receive the third through fifth result set. The only difference I see from the stored procedure is that the first two result sets are "Select"s from local variables (ie @headertxt) and the third through the fifth result set are "Select"s from temporary (#tmptble) tables. I can't determine the root cause of why I can't see the third though fifth result set. I have "set nocount on" in the procedure. I have executed the stored procedure in Query Analyzer under the same ID/PW that I'm setting the connection with in the VBS. No errors are generated from the execution of the stored procedure. I'm running MDAC 2.81 on the workstation.
VBS:

dim Conn, strProvider, rs, SQL, i, j

dim asoftime, errorcode, cur1, cur2, atype, asofdate, display_title



'Get the data

Set Conn = Wscript.CreateObject("ADODB.Connection")



Conn.CommandTimeout = 60

Conn.ConnectionTimeout = 60

dim datasource

datasource = "xxxxxxxxx"



strProvider = "Provider=SQLOLEDB; Data Source=" & datasource & "; Initial Catalog=s; User ID=frndis; Password=frndis1; Connect Timeout=15; Persist Security Info=True;UseProcForPrepare=0"

SQL = "exec s.dbo.prcWebGetMostActiveSongs @currency = 'USD'"



Conn.Open strProvider



Set rs = Conn.Execute(SQL)



asoftime = rs(0)



wscript.echo asoftime, rs.Fields.Count



set rs = rs.nextrecordset

cur1 = rs(0)

cur2 = rs(1)

atype = rs(2)

display_title = replace(rs(3), "&", "&amp;")





wscript.echo cur1

wscript.echo cur2

wscript.echo atype

wscript.echo display_title, rs.Fields.Count



set rs = rs.nextrecordset



wscript.echo rs.Fields.Count



'grand total

while (not rs.eof)

for i = 0 to rs.Fields.Count - 1

wscript.echo rs(i)

next



rs.movenext



wend

wscript.echo "finished grand"



set rs = rs.nextrecordset

'mostactive total

while (not rs.eof)



rs.movenext



wend

wscript.echo "finished MA"



set rs = rs.nextrecordset

i = 0

'details

while (not rs.eof)

i = i + 1

rs.movenext



wend

wscript.echo "finished details", i





rs.close

Conn.Close

set rs = nothing

set Conn = nothing


Thanks,

Sid

View 5 Replies View Related

Multiple Data Sets In One List

Mar 24, 2008

Is there a way to put more then one data set in a list.
I have a report that has three data sets with three tables. Now i want to show each report by Region, per page. So you can view the same stuff for each region seperately, instead of all together. Is there a way to do this. Where i dont have to go back in my code, and find a way to link everything together, so its in one data set .

View 3 Replies View Related

How To Do A Report With Multiple Sets Of Details For One Group

Mar 4, 2008



Hi,
I started working with SRS from the past one month. I am breaking my head to do this. My report has a single stored procedure. I made it to work all values of a parameter like
exec sp_employee 'All' (Returns data for all employees)
exec sp_employee '1111' (Returns data for an employee with id 1111)
exec sp_employee '1111,2222' (Returns data for an employee with id 1111 as well as 2222)

This part works perfectly. I could successfully pass the values as mentioned above using a code block.

Now my challenge is how to layout the data on the report.

I need to show the report as follows:

Employeeid Employee Name Address etc.......
Skills:
Skill# Skill Name
1 11111
2 22222
3 33333
4 44444
Contacts:
Contact Type Contact#
Main 111-1111
Emergency 222-1111
Eductation:
Name University
Degree UofU
Masters UofU

I tried using group by employeeid. But i can only show one group of data either Skills/Contacts/Education.
I do not know if I use sub-report, how to pass the parameter from the main, when I pick multiple values for Employeeid.

Any idea how to do this? I appreciate your help,
Thank you,



View 3 Replies View Related

Making A Chart Run With Multiple Data Sets.

Jul 26, 2007

Hello and thanks in advance.

I was wondering if anyone has ever written a chart with multiple datasets.

I need to be able to show sales dollars inflow by order date on one line and on the other needs to be sales dollars delivered by delivery date. So the all sections Values, Category groups, and Series Groups in the chart will be from 2 different datasets.

I have tried but it will not allow aggreates in the series groups.

Any Ideas would be greatly appreciated.

Thanks, Leo

View 1 Replies View Related

Result Sets Using Select In Query Anlyzer Vs BCP Vs Select Into

Jul 9, 2002

When I run simple select against my view in Query Analyzer, I get result set in one sort order. The sort order differs, when I BCP the same view. Using third technique i.e. Select Into, I have observed the sort order is again different in the resulting table. My question is what is the difference in mechanisim of query analyzer, bcp, and select into.
Thanks

View 1 Replies View Related

SQL 2005 Unexplained Error When Opening Recordset Or Multiple Sets

Aug 12, 2007

To anyone that can help me

we have a application written in straight ASP, we recently upgraded our SQL database connecting to the application from SQL 2000 to 2005 here is the issue

currently SQL 2005 is located in our test and UAT environments, SQL 2005 is not clustered in either location. Now let me make it clear THIS PROBLEM IS NOT HAPPENING IN OUR TEST ENVIRONMENT, I REPEAT THIS PROBLEM IS NOT HAPPENING IN OUR TEST ENVIROMENT, THIS PROBLEM IS ONLY HAPPENING IN OUR UAT ENVIROMENT

Each enviroment is outfitted with the following SQL 2005 environment, Enterprise Edition SP1 with Cumlative hotfix package 2153 just the SISS fix ONLY

now the problem is this, we have a vb program located directly on the server that has SQL 2005 on it that VB program inserts a timestamp into a table inside the database, now how this happens is the program connects to the database and opens a recordset with a forwardonly cursor and inserts the timestamp

NOW THE EXACT PROBLEM IS THAT THE VB PROGRAM CANNOT OPEN MULTIPLE RECORDSETS, THE ERROR RECEIVED IS LABLED LIKE THIS

ODBC DRIVER ERROR 8000405 SHARED MEMORY SQL DOESNT EXIST OR ACCESSED DENIED,

NOW here is the interesting part, AGAIN THIS IS NOT HAPPENING IN OUR TEST ENVIRONMENT, THE VB PROGRAM AGAIN IS ON THE TEST SQL SERVER AND HAS A FORWARD ONLY CURSOR AND INSERTS JUST FINE

NOW IF I MOVE THE VB PROGRAM OUT OF OUR UAT ENVIRONMENT ONTO ANOTHER SERVER IT INSERTS THE RECORD ONTO SQL SERVER JUST FINE, IT OPENS THE RECORDSET AND OPERATES NORMALLY, BOTH SERVERS HAVE EXACT SAME PERMISSIONS

Can anyone help me understand whats happening here

One note, when we changed the cursortype from forward-only to keyset it worked fine but that doesnt explain things

why does it work in test so clearly what we did with changing the cursortype isnt the answer

Thanks please consider this a urgent request

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved