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), "&", "&")





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


ADVERTISEMENT

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

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 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 View Related

Multiple Active Result Sets

Mar 29, 2007

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

View 6 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

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

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

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

Identifying Results Sets When Stored Procedure Called Multiple Times

Oct 18, 2005

I have a report based on our product names that consists of two parts.Both insert data into a temporary table.1. A single grouped set of results based on all products2. Multiple tables based on individual product names.I am getting data by calling the same stored procedure multipletimes... for the single set of data I use "product like '%'"To get the data for individual products, I am using a cursor to parsethe product list.It's working great except that I have no idea how to identify theresults short of including a column with the product name. While thatis fine, I'm wondering if there is something that is like a header ortitle that I could insert prior to generating the data that would looka little tighter.Thanks in advance-DanielleJoin Bytes!

View 3 Replies View Related

TableName Property In Conditional Multiple Recordset

Dec 29, 2007

Hi everyone,

I'm using a stored procedure in SQL Server to generate multiple recordsets. The recordset are however generated conditionally. create procedure GetData
(
@a bit
@b bit
)

Select * from Customers

IF(@a=1)
Select * from Products

IF(@b=1)
Select * from Details ------------Issue:The adapter returns the table named as Table, Table1(optional) and Table2(optional). It might be that Table1 is products or Table1 is Details.How can I map my tablename property in this scenario where the sequence of tables is not known.   

View 3 Replies View Related

T-SQL (SS2K8) :: Nested Stored Procedure - Multiple Results Of Record Sets Coming

Oct 1, 2014

I am calling stored procedure called GetCommonItemCount within another stored procedure called CheckBoxAvailability, the first stored procedure should return a count to second stored procedure and based on that some logic will be executed.

I have 2 problems in that

1. The result is not coming from first stored so the variable called @Cnt is always 0 although it should be 18
2. At the end i need to see in the output the result from second stored procedure only while now i am seeing multiple results of record sets coming.

I have attached the scripts also, the line i described in step1 is

View 9 Replies View Related

Integration Services :: Reading Recordset Multiple Times Gives 0 Rows

Oct 26, 2013

I have an EXECUTE SQL Task, which gets a result-set from SQLServer using OLEDB Connection.

The result set is mapped to an object variable , say @[User::FilePath]

There are 33 row is the above resultset.

Then, I have a For-each loop, inside which, I have a Script task .

I am trying to put the aboveĀ @[User::FilePath] recordset into a DataTable using DataAdapter.Fill() function. I perform some read operations to its rows.

The problem is , in the First Iteration of For-Each-Loop, the number of rows in data-table shows 33.

But from the Next Iteration, it comes out to be 0. (ZERO!!)

This causes my package to fail.

View 5 Replies View Related

Multiple Reads Of User Variable (Recordset Object) Failing

Mar 1, 2007

I hope this is a simple question. I have a package-scope user variable which is populated using a Recordset Destination in a Data Flow task. I am attempting to read the variable multiple times from different Script Tasks. The first read works fine, however the second read, in the second Script Task, says that there are no rows.

Has anyone run across this before? Any thoughts would be appreciated.

Thanks





View 1 Replies View Related

Moving Multiple Databases Of 500GB

May 3, 2006

Hi

I have to move 5 Databases from production server to another server. I know it can be done by Backup and Restore and then make sure that all User names, Passwords and roles are not changed.

Some one can please help me out in giving a step by step process.

Thanks.
Bob

View 1 Replies View Related

SSIS Moving Multiple Files

Nov 15, 2007

I have a number of XLS reports in template form. I want to move these to a new location on the File Server and after they have been populated move them to another location on the File Server.

I have seen some proposed solutions but I haven€™t found any that work. This should not be difficult and I envisage using a File System Task and a Foreach Loop Container. However passing the multiple file names to the File System Task errors repeatedly.

Any help would be greatly appreciated!!

Paul Boynton

View 13 Replies View Related

Transact SQL :: How To Get Moving Total Like Moving Average

Nov 10, 2015

I trying to get the moving total (juts as moving average). It always sum up the current record plus previous two records as well and grouped by EmpId.For example, attaching a image of excel calculation.

View 3 Replies View Related

MDX Help With Sets

May 21, 2008

Hello,

I'm new to MDX and was hoping someone could answer this question. I'm working on an MDX query, a simplified version is below.

What I'm trying to do is to pull 2 sets, based on a date range. Based on those, I'd like to see the total "cost" measure for each set, and divide one by another.

What I'm finding is that when I run the query below, the cost is broken out by month. So, my select statement gives me the cost for January 2008 and February 2008 in the CurrentPeriod set, and for January, February, etc. 2007 in the PriorPeriodData set. What I want instead is to get the total "cost" measure for all the months in each set. I believe this is what I'd get if I put the date range in a subcube or a where clause - but in that case, I wouldn't be working with 2 distinct sets.

Is there some other way to write this, or to combine all the months in the set before the measures?



WITH

SET [CurrentPeriod] AS

'{[Activity Date].[Date].&[2008-01-01T00:00:00]:[Activity Date].[Date].&[2008-02-01T00:00:00]}'

SET [PriorPeriod] AS

'{[Activity Date].[Date].&[2007-01-01T00:00:00]:[Activity Date].[Date].&[2007-12-01T00:00:00]}'

MEMBER [Measures].[Cost Variance] AS

'([CurrentPeriod],[Measures].[Cost]) /

([PriorPeriodData],[Measures].[Cost])'

SELECT NON EMPTY {

([CurrentPeriod],[Measures].[Cost]),

([PriorPeriodData],[Measures].[Cost]),

([Measures].[Cost Variance])

} ON COLUMNS

FROM [Cube]


Thanks for your help!

View 3 Replies View Related

SQL Sets Query

Apr 21, 2003

PLEASE SEE my update (post #3) for a better simpler explanation!!!!!

Hi,
I need a query which is basically

(query 1)
Except
(query 2)

SQL server supports
(query 1)Union (query 2)
but I can't get the Except to work.

Alternatively,
I also tried to implement it by using the "NOT IN" but didnt work.
Background: 3 tables, accnts, Opty, Opty_postn
I want
the accounts who have 1 or more opty's at 100% (sold) before 1/1/2002 but zero opty's at 100% after 12/31/2001.
accnts has fields ID & name, ROW_ID
opty has fields acct_id, prob, ROW_ID
opty_postn has fields opty_id, close_dt

My query:
SELECT accnt.name
FROM accnt
WHERE
accnt.ROW_ID IN
(
SELECT acct_id
FROM opty
where prob = 100
AND opty.ROW_ID IN
(SELECT opty_id
FROM opty_postn
WHERE close_dt<1/1/2002)
)
AND accnt.ROW_ID NOT IN
(
SELECT acct_id
FROM opty
where prob = 100
AND opty.ROW_ID IN
(SELECT opty_id
FROM opty_postn
WHERE close_dt >12/31/2001)
)
AND accnt.ROW_ID = opty.accnt_ID

my intent was
select account.names
where id
is in set(prob = 100 & sale before 1/1/02)
but not in ( prob = 100 & sale after 21/31/01)
SO ,the accounts which have sales both before and after get counted. But I want only those accoutns which have sales only before 1/1/02.
I hope i explained this right.
Thanks in advance for your help.

Ash.

View 14 Replies View Related

Named Sets???

Dec 18, 2004

Hi,

Can someone briefly explain which this feature of Analysis services is and how canit be of use.

Also, besides BOL, I'll appreciate if someone can recommend a good reading on this.

Thanks.

View 2 Replies View Related

Using 2 Different Measures And 2 Different Sets

Jan 31, 2005

Hello.



i have dimensions: month, country, customer, item.
measures: amount, price.

i would like to get such result :

for each customer from USA: sum (amount of item in June * price for the same
item in January).

is it possible?

thank you for your help, Mike.

View 2 Replies View Related

Overlapping Sets

Apr 24, 2007

I have the following table structure

CREATE TABLE [dbo].[QDisc](
[Id] [int] NOT NULL,
[MinVal] [int] NOT NULL,
[MaxVal] [int] NOT NULL,
[PerVal] [int] NOT NULL,
CONSTRAINT [PK_QDisc] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]

I need to be able to select unique overlapping sets of data based on the minval and maxval.

Simple Example
minval maxval
5 15
16 25
10 20

query would produce
minval maxval
5 10
11 15
16 20
21 25

More Complex example
minval maxval
5 15
16 25
10 20
7 7
1 100

query would produce
minval maxval
1 5
6 6
7 7
8 10
11 15
16 20
21 25
26 100

Extra points if anyone can do this without SP and cursor but I'd be satisfied if someone supplied it that way.

View 9 Replies View Related

Dynamic Sets? (i.e. Where X In (@set))

Jul 20, 2005

Hi,I've tried without success to create a function where one of theparameters determines the final line of a select statement.The final line includes a 'where referencenumber in (@set)' line.. and@set is the parameter I wish to use which is a string.If the set is just one value, it works fine, however with anything morethan that I just get no records returned.. If I output the parameter,and copy and paste that into query analyser I do get the correct result,so it's nothing to do with string delimiters etc..Any ideas to fix this problem? Or am I going to have to dynamic sql thewhole thing?Cheers,Chris

View 2 Replies View Related

Working With Sets

Aug 17, 2006

I need to manipulate some sets, doing joins based on intersection, and looking for subsets. Is there any way to store an array in a single data field? And then do operations based on those array lists? e.g. -

{1,2,3} intersect {2,3,4} ==> {2,4} (would like to then be able to do joins based on intersection, so that I could say, return all cases where two sets have all but one member from each in common...)

View 3 Replies View Related

Large Data Sets

Mar 20, 2008

Hi,
 I'm currently trying to retrieve results from a large dataset, there are over 45000 records and I need to use them all to peform counts etc.  I have set up views, but my page is still being returned slowly, is there anything I can do to speed this up?
 Thanks
 Gemma

View 2 Replies View Related

Query With 2 Sets Of Data

May 7, 2008

I am trying to query one table and get two different timeperiods of data, I am summing monthly totals to provide a running year total, but I also need last month's total in a seperate column. This is what I have so far but the subquery makes me group it which provides duplicate grouping.DECLARE @LASTPD AS INT
SET @LASTPD = (SELECT MAX(LASTPERIOD) FROM TABLE)
SELECT NAME,
POST_PD AS [MONTH],SUM(CHARGE_AMOUNT) AS MONTHLY_$,
LASTMONTH.LAST_MONTH,(SELECT SUM(CHARGE_AMOUNT) AS LAST_MONTH
FROM TABLE INNER JOIN TABLE2
ON TABLE2.NAME = TABLE.NAME
WHERE POST_PD = @LASTPD
AND TABLE2.NUM= 539
GROUP BY NAME) AS LASTMONTH
INTO #TEMP_SAFROM TABLE
INNER JOIN TABLE2
ON TABLE2.NAME = TABLE.NAME,(SELECT SUM(CHARGE_AMOUNT) AS LAST_MONTH
FROM TABLEWHERE TABLE2.NUM = 539
GROUP BY NAME, POST_PDORDER BY NAME, POST_PD
SELECT NAME,
             LAST_MONTH,
CAST(SUM(MONTHLY_$)AS DECIMAL(20,2)) AS YEARLY_$
FROM #TEMP_SA
GROUP BY NAME
ORDER BY NAME

View 13 Replies View Related

Dts And Char Sets - Upgrading

Jul 31, 2000

I need to upgrade a 6.5 box to 7.0 but also change the character sets. Let me know how this sounds.

-Have a 2nd machine w/ 6.5 on it and same char sets.
-backup/restore data from prod box to 2nd machine.
-upgrade 2nd machine to 7.0 using the same char sets.
-uninstall prod machine and install 7.0 w/ new char set.
-use dts to move data from 2nd machine to new machine. (changing char sets from old to new)

View 4 Replies View Related

Disconnected Record Sets

Oct 28, 1999

We're constructing a three-tier application. We want the middle tier to
extract a recordset from the database, disconnect from the database,
then pass the recordset to the front tier. After changes have been made
by the front tier, it will pass the recordset back to the middle tier,
which will reconnect, and update the database.
The problem:
Using stored procedures, the recordset is no longer available
once the connection has been closed. Is there any way, using stored
procedures, to be able to keep the recordset available after the
connection has been closed, either by preserving it, copying it, or
otherwise?

View 1 Replies View Related

How To Combine 2 Sets Of Group By ........

Dec 11, 2007

Hi:

How can I combine 2 sets of group by together?

same criteria on group by Region, county

setA with where sum(timeSec) <= 30

while setB with where sum(timeSec) > 30

they are not necessary mutual exclusive. thus, union is not good.
However, when I use derived table method, I will have 'dups' on column of 'Region' and 'county', 2 total are fine.

thanks
David

View 2 Replies View Related







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