I can not assign more than one variable using this cursor:
DECLARE Itemid_Cursor CURSOR FOR
select distinct itemid,itemname from items
OPEN Itemid_Cursor
FETCH NEXT FROM Itemid_Cursor
INTO @.itemid,@.itemnameWhat does "can not" mean? Do you get an error message? If so, what is it?
<uri@.bwayphoto.com> wrote in message
news:1139251594.154562.102910@.g43g2000cwa.googlegroups.com...
>I can not assign more than one variable using this cursor:
>
> DECLARE Itemid_Cursor CURSOR FOR
> select distinct itemid,itemname from items
> OPEN Itemid_Cursor
> FETCH NEXT FROM Itemid_Cursor
> INTO @.itemid,@.itemname
>|||The @.itemname variable does not get populated.|||Can you post all of the relevant actual code?
Andrew J. Kelly SQL MVP
<uri@.bwayphoto.com> wrote in message
news:1139251594.154562.102910@.g43g2000cwa.googlegroups.com...
>I can not assign more than one variable using this cursor:
>
> DECLARE Itemid_Cursor CURSOR FOR
> select distinct itemid,itemname from items
> OPEN Itemid_Cursor
> FETCH NEXT FROM Itemid_Cursor
> INTO @.itemid,@.itemname
>|||Well, you're going to have to provide DDL and sample data... what you've
provided so far is not enough to give you an answer.
See http://www.aspfaq.com/5006
<uri@.bwayphoto.com> wrote in message
news:1139251923.570483.247690@.o13g2000cwo.googlegroups.com...
> The @.itemname variable does not get populated.
>|||<uri@.bwayphoto.com> wrote in message
news:1139251923.570483.247690@.o13g2000cwo.googlegroups.com...
> The @.itemname variable does not get populated.
Maybe you have NULLs in that column.|||Thanks Andrew, I removed the non-relevant code and it worked.
I had some other bug.
Thanks again.|||*doh*
<uri@.bwayphoto.com> wrote in message
news:1139253728.769033.207820@.g14g2000cwa.googlegroups.com...
> Thanks Andrew, I removed the non-relevant code and it worked.
> I had some other bug.
> Thanks again.
>|||I tried this and works fine:
-- CREATE TEST TABLE
create table items
(
itemid int
, itemname varchar(50)
)
-- POPULATE TEST TABLE
insert into items
values (1, 'Item1')
insert into items
values (2, 'Item2')
insert into items
values (3, 'Item3')
-- BEGIN SCRIPT
declare @.itemid int
, @.itemname varchar(50)
DECLARE Itemid_Cursor CURSOR FOR
select distinct itemid,itemname from items
OPEN Itemid_Cursor
FETCH NEXT FROM Itemid_Cursor
INTO @.itemid,@.itemname
while @.@.fetch_status = 0
begin
select @.itemid,@.itemname
FETCH NEXT FROM Itemid_Cursor INTO @.itemid,@.itemname
end
close Itemid_Cursor
deallocate Itemid_Cursor
-- DROP TEST TABLE
drop table items
"uri@.bwayphoto.com" wrote:
> I can not assign more than one variable using this cursor:
>
> DECLARE Itemid_Cursor CURSOR FOR
> select distinct itemid,itemname from items
> OPEN Itemid_Cursor
> FETCH NEXT FROM Itemid_Cursor
> INTO @.itemid,@.itemname
>
Showing posts with label variable. Show all posts
Showing posts with label variable. Show all posts
Wednesday, March 21, 2012
Wednesday, March 7, 2012
Multiple set result from a stored procedure as the data source
My stored procedure generates two results:
1) declares a variable executes a view to obtain date driven data which has
a begin and end
2) selects the data associated with date driven info
When RS executes the stored procedure I only get the first set results (the
date information).
Can RS handle multiple results from a stored procedure? If so is there any
information to read.
I can change my stored procedure with a couple joins but I am curious how RS
works (I'm a newbee).
SincerelyRS only works with the first resultset.
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"HelpInRS" <HelpInRS@.discussions.microsoft.com> wrote in message
news:CDADB1FA-43D3-40A0-BD94-CFD98F9FAFCE@.microsoft.com...
> My stored procedure generates two results:
> 1) declares a variable executes a view to obtain date driven data which
has
> a begin and end
> 2) selects the data associated with date driven info
> When RS executes the stored procedure I only get the first set results
(the
> date information).
> Can RS handle multiple results from a stored procedure? If so is there any
> information to read.
> I can change my stored procedure with a couple joins but I am curious how
RS
> works (I'm a newbee).
> Sincerely|||Sorry...RS doesn't support multiple result sets.
Adrian M.
"HelpInRS" <HelpInRS@.discussions.microsoft.com> wrote in message
news:CDADB1FA-43D3-40A0-BD94-CFD98F9FAFCE@.microsoft.com...
> My stored procedure generates two results:
> 1) declares a variable executes a view to obtain date driven data which
> has
> a begin and end
> 2) selects the data associated with date driven info
> When RS executes the stored procedure I only get the first set results
> (the
> date information).
> Can RS handle multiple results from a stored procedure? If so is there any
> information to read.
> I can change my stored procedure with a couple joins but I am curious how
> RS
> works (I'm a newbee).
> Sincerely|||Thanks for the info
"Adrian M." wrote:
> Sorry...RS doesn't support multiple result sets.
> Adrian M.
> "HelpInRS" <HelpInRS@.discussions.microsoft.com> wrote in message
> news:CDADB1FA-43D3-40A0-BD94-CFD98F9FAFCE@.microsoft.com...
> > My stored procedure generates two results:
> > 1) declares a variable executes a view to obtain date driven data which
> > has
> > a begin and end
> > 2) selects the data associated with date driven info
> >
> > When RS executes the stored procedure I only get the first set results
> > (the
> > date information).
> >
> > Can RS handle multiple results from a stored procedure? If so is there any
> > information to read.
> >
> > I can change my stored procedure with a couple joins but I am curious how
> > RS
> > works (I'm a newbee).
> >
> > Sincerely
>
>
1) declares a variable executes a view to obtain date driven data which has
a begin and end
2) selects the data associated with date driven info
When RS executes the stored procedure I only get the first set results (the
date information).
Can RS handle multiple results from a stored procedure? If so is there any
information to read.
I can change my stored procedure with a couple joins but I am curious how RS
works (I'm a newbee).
SincerelyRS only works with the first resultset.
--
Bruce Loehle-Conger
MVP SQL Server Reporting Services
"HelpInRS" <HelpInRS@.discussions.microsoft.com> wrote in message
news:CDADB1FA-43D3-40A0-BD94-CFD98F9FAFCE@.microsoft.com...
> My stored procedure generates two results:
> 1) declares a variable executes a view to obtain date driven data which
has
> a begin and end
> 2) selects the data associated with date driven info
> When RS executes the stored procedure I only get the first set results
(the
> date information).
> Can RS handle multiple results from a stored procedure? If so is there any
> information to read.
> I can change my stored procedure with a couple joins but I am curious how
RS
> works (I'm a newbee).
> Sincerely|||Sorry...RS doesn't support multiple result sets.
Adrian M.
"HelpInRS" <HelpInRS@.discussions.microsoft.com> wrote in message
news:CDADB1FA-43D3-40A0-BD94-CFD98F9FAFCE@.microsoft.com...
> My stored procedure generates two results:
> 1) declares a variable executes a view to obtain date driven data which
> has
> a begin and end
> 2) selects the data associated with date driven info
> When RS executes the stored procedure I only get the first set results
> (the
> date information).
> Can RS handle multiple results from a stored procedure? If so is there any
> information to read.
> I can change my stored procedure with a couple joins but I am curious how
> RS
> works (I'm a newbee).
> Sincerely|||Thanks for the info
"Adrian M." wrote:
> Sorry...RS doesn't support multiple result sets.
> Adrian M.
> "HelpInRS" <HelpInRS@.discussions.microsoft.com> wrote in message
> news:CDADB1FA-43D3-40A0-BD94-CFD98F9FAFCE@.microsoft.com...
> > My stored procedure generates two results:
> > 1) declares a variable executes a view to obtain date driven data which
> > has
> > a begin and end
> > 2) selects the data associated with date driven info
> >
> > When RS executes the stored procedure I only get the first set results
> > (the
> > date information).
> >
> > Can RS handle multiple results from a stored procedure? If so is there any
> > information to read.
> >
> > I can change my stored procedure with a couple joins but I am curious how
> > RS
> > works (I'm a newbee).
> >
> > Sincerely
>
>
Subscribe to:
Posts (Atom)