Home All Groups Group Topic Archive Search About

dynamic columns/aliases - Continue

Author
15 Sep 2005 6:23 PM
romy
Hi

Following my previous question. Here is the implemetation.

I have to design a report which display monthes as columns.
The number of columns in the report depends on the range paramters.
For example : if the Range is from 01/02/05  to 30/06/05 there ara 6 columns
shown.

01/05,02/05.....06/05. (column alias) .
if the range of dates are 8 monthes range there are 8 dynamic columns, etc'

1) My first major problem is to write a SP or a function that return a
dynamic number of columns.
2) Second,(This is not a must) to change column alias (Heading) according to
the parameters.


thanks

Author
15 Sep 2005 5:44 PM
David Portas
What reporting tool do you use? This is called a cross tab report and
any decent reporting tool will render it for you client-side with no
programming required. Otherwise you'll have to use dynamic SQL, which
is not much fun.

--
David Portas
SQL Server MVP
--
Author
16 Jul 2005 8:20 AM
romy
Yes. My Big Problem is indeed the Reporting tool which is Custom Reporting
tool of an ERP software that simply translate
the resulted query to a GUI look alike Report.
Unfortunately , There's Nothing I can do about it.

What are my options with dynamic sql ?

Show quote
"David Portas" <REMOVE_BEFORE_REPLYING_dpor***@acm.org> wrote in message
news:1126806242.941597.208120@g44g2000cwa.googlegroups.com...
> What reporting tool do you use? This is called a cross tab report and
> any decent reporting tool will render it for you client-side with no
> programming required. Otherwise you'll have to use dynamic SQL, which
> is not much fun.
>
> --
> David Portas
> SQL Server MVP
> --
>
Author
15 Sep 2005 8:03 PM
--CELKO--
>> 1) My first major problem is to write a SP or a function that return a dynamic number of columns. <<

NO, your **first** problem is that you missed the basic concepts of
RDBMS.  A query returns a table; a table has a fixed number of columns.
A query is not a report; a query sends information to a front end
which can have a reporting tool in it.

This is definitions, not anything fancy.

\If you want to be a bad SQL programmer, this can be done with dynamic
SQL and a ton of procedural code that will be a bitch to maintain.

AddThis Social Bookmark Button