i have a report that needed to create many dataset(coz its complicated
to combine all of the using union).the problem is how can i combine it
all at the layout and make a link to all of them...i have try using
many table but in the end, the result is not what i expected...so how
do i link it?if using table how can i link the table with each
other...<<<<tq>>You can't really combine datasets. You are going to have to either generate a
query in the report designer or write a stored procedure which extracts data
from your different tables/data sources.
The only other thing you can do is design a subreport of your main report.
This can use a different dataset, but there must be some link between the two
which you specify.
HTH,
Magendo_man
"wiraperkasa" wrote:
> i have a report that needed to create many dataset(coz its complicated
> to combine all of the using union).the problem is how can i combine it
> all at the layout and make a link to all of them...i have try using
> many table but in the end, the result is not what i expected...so how
> do i link it?if using table how can i link the table with each
> other...<<<<tq>>
>|||tq magendo_man..ok i know how to generate a query in the report
designer...but write a stored procedure...i'm not quite sure about
it..can you explain to me...
and also..how to use the subreport(is it at the layout?) and hoe to
link between the two dataset..if u have any website that u want to
recommend...:)...tq|||You need to have access to the SQL server database to write a stored
procedure. It can take the form of a query, very similar to those you
generate in Visual Studio for Reporting Services. If you are using SQL 2000
you will probably need to use SQL Server Enterprise Manager and/or SQL Query
Analyzer.
You create a sub-report as you would any normal report in Visual Studio,
i.e. as a seperate report. You then need to go to your main report design and
drag a sub-report control on to the report body and configure the link to
your previously created sub-report. You should get info about this in the
help for Reporting Services in Visual Studio.
HTH,
Magend_man
"wiraperkasa" wrote:
> tq magendo_man..ok i know how to generate a query in the report
> designer...but write a stored procedure...i'm not quite sure about
> it..can you explain to me...
> and also..how to use the subreport(is it at the layout?) and hoe to
> link between the two dataset..if u have any website that u want to
> recommend...:)...tq
>|||maybe we can try to use sub-report...
"magendo_man" wrote:
> You need to have access to the SQL server database to write a stored
> procedure. It can take the form of a query, very similar to those you
> generate in Visual Studio for Reporting Services. If you are using SQL 2000
> you will probably need to use SQL Server Enterprise Manager and/or SQL Query
> Analyzer.
> You create a sub-report as you would any normal report in Visual Studio,
> i.e. as a seperate report. You then need to go to your main report design and
> drag a sub-report control on to the report body and configure the link to
> your previously created sub-report. You should get info about this in the
> help for Reporting Services in Visual Studio.
> HTH,
> Magend_man
> "wiraperkasa" wrote:
> > tq magendo_man..ok i know how to generate a query in the report
> > designer...but write a stored procedure...i'm not quite sure about
> > it..can you explain to me...
> > and also..how to use the subreport(is it at the layout?) and hoe to
> > link between the two dataset..if u have any website that u want to
> > recommend...:)...tq
> >
> >
Showing posts with label union. Show all posts
Showing posts with label union. Show all posts
Friday, March 9, 2012
how to limits recors from a UNION query
I use SQL2000 and I have a query like this:
select * from TabA where 'somecondition'
UNION
select * from TabB where 'somecondition'
order by 'somefield'
I need to limit maximun number of records from this query; problem is that
maybe query A get a lot of records and query B get few records: if i put a
TOP clause in every query i don't reach my purpose. Is there a way to put a
globally TOP clause?How about :
SELECT TOP 100 * FROM
(SELECT * FROM TabA WHERE 'somecondition'
UNION (ALL?)
SELECT * FROM TabB WHERE 'somecondition
ORDER BY 'whatever) AS DerivedTable
Performance? That is another question, isn't it?
RLF
"StefanoMaind" <StefanoMaind@.discussions.microsoft.com> wrote in message
news:17A0C91D-5374-4E71-8C13-3D0BCE406D6C@.microsoft.com...
>I use SQL2000 and I have a query like this:
> select * from TabA where 'somecondition'
> UNION
> select * from TabB where 'somecondition'
> order by 'somefield'
> I need to limit maximun number of records from this query; problem is that
> maybe query A get a lot of records and query B get few records: if i put a
> TOP clause in every query i don't reach my purpose. Is there a way to put
> a
> globally TOP clause?
>|||SELECT TOP 10 col1, col2, ...
FROM
(
select col1, col2, ... from TabA where 'somecondition'
UNION
select col1, col2, ... from TabB where 'somecondition'
) AS i
order by 'somefield'
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"StefanoMaind" <StefanoMaind@.discussions.microsoft.com> wrote in message
news:17A0C91D-5374-4E71-8C13-3D0BCE406D6C@.microsoft.com...
>I use SQL2000 and I have a query like this:
> select * from TabA where 'somecondition'
> UNION
> select * from TabB where 'somecondition'
> order by 'somefield'
> I need to limit maximun number of records from this query; problem is that
> maybe query A get a lot of records and query B get few records: if i put a
> TOP clause in every query i don't reach my purpose. Is there a way to put
a
> globally TOP clause?
>|||Thanks to all
"Tibor Karaszi" wrote:
> SELECT TOP 10 col1, col2, ...
> FROM
> (
> select col1, col2, ... from TabA where 'somecondition'
> UNION
> select col1, col2, ... from TabB where 'somecondition'
> ) AS i
> order by 'somefield'
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "StefanoMaind" <StefanoMaind@.discussions.microsoft.com> wrote in message
> news:17A0C91D-5374-4E71-8C13-3D0BCE406D6C@.microsoft.com...
>
select * from TabA where 'somecondition'
UNION
select * from TabB where 'somecondition'
order by 'somefield'
I need to limit maximun number of records from this query; problem is that
maybe query A get a lot of records and query B get few records: if i put a
TOP clause in every query i don't reach my purpose. Is there a way to put a
globally TOP clause?How about :
SELECT TOP 100 * FROM
(SELECT * FROM TabA WHERE 'somecondition'
UNION (ALL?)
SELECT * FROM TabB WHERE 'somecondition
ORDER BY 'whatever) AS DerivedTable
Performance? That is another question, isn't it?
RLF
"StefanoMaind" <StefanoMaind@.discussions.microsoft.com> wrote in message
news:17A0C91D-5374-4E71-8C13-3D0BCE406D6C@.microsoft.com...
>I use SQL2000 and I have a query like this:
> select * from TabA where 'somecondition'
> UNION
> select * from TabB where 'somecondition'
> order by 'somefield'
> I need to limit maximun number of records from this query; problem is that
> maybe query A get a lot of records and query B get few records: if i put a
> TOP clause in every query i don't reach my purpose. Is there a way to put
> a
> globally TOP clause?
>|||SELECT TOP 10 col1, col2, ...
FROM
(
select col1, col2, ... from TabA where 'somecondition'
UNION
select col1, col2, ... from TabB where 'somecondition'
) AS i
order by 'somefield'
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"StefanoMaind" <StefanoMaind@.discussions.microsoft.com> wrote in message
news:17A0C91D-5374-4E71-8C13-3D0BCE406D6C@.microsoft.com...
>I use SQL2000 and I have a query like this:
> select * from TabA where 'somecondition'
> UNION
> select * from TabB where 'somecondition'
> order by 'somefield'
> I need to limit maximun number of records from this query; problem is that
> maybe query A get a lot of records and query B get few records: if i put a
> TOP clause in every query i don't reach my purpose. Is there a way to put
a
> globally TOP clause?
>|||Thanks to all
"Tibor Karaszi" wrote:
> SELECT TOP 10 col1, col2, ...
> FROM
> (
> select col1, col2, ... from TabA where 'somecondition'
> UNION
> select col1, col2, ... from TabB where 'somecondition'
> ) AS i
> order by 'somefield'
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
> Blog: http://solidqualitylearning.com/blogs/tibor/
>
> "StefanoMaind" <StefanoMaind@.discussions.microsoft.com> wrote in message
> news:17A0C91D-5374-4E71-8C13-3D0BCE406D6C@.microsoft.com...
>
Subscribe to:
Posts (Atom)