Showing posts with label hiis. Show all posts
Showing posts with label hiis. Show all posts

Monday, March 26, 2012

Dynamic Pivot

Hi

Is there a way for using the PIVOT synatx with a dyamic/unknown list of columns? In most PIVOT examples ther columns are "hard" coded but if for example, you are pivoting a sales order table where u don't know which Fiscal Years the orders cover, how could you do this?

Thanks

Hi,

I followed a link http://www.sqlmag.com/Article/ArticleID/43140/sql_server_43140.html

and get this one working in another forum.

http://forums.asp.net/2/1392175/ShowThread.aspx#1392175

If you have question for that, please let me know.

|||Thanks limno, this helps a lot

Monday, March 19, 2012

Dynamic labels in chart.

Hi
Is there a way in which I can set the labels for the X and Y axes for a chart programatically? The values for the labels are returned from the database...

I already have a stored proc which acts as the source for the chart. I might have the labels retrieved as a seperate query from the DB.

ThanksThe Y-axis labels are determined by the chart control and are numeric values. You can set the format code property to get special numeric formatting and locale settings.

The X-axis has two modes: numeric ("timescale or numeric values" checkbox) and non-numeric (default). In the non-numeric mode, the labels are determined by the category grouping value expression or the category grouping label expression (if explicitly specified).

-- Robert|||Thanks....

Can we also display the Titles for the X and Y-axes from the database? I have one query that generates the data for the report...

I was wondering if I could set the Titles for these axes from a seperate query from the Database.

Thanks
Kannan

Wednesday, February 15, 2012

dynamic aliases/columns

Hi
Is it possible to return a table that its aliases are changing according to
varaiables ?
For example: I would like to use something like (ofcourse it doesn't work).
declare @.p1,@.p2 varchar(30)
set @.p1 ='blhablha'
set @.p2 ='hghfg'
select field1 as @.p1, field2 as @.p2 from table1Only with dynamic SQL (sp_executesql or exec). Most of the time,
however, dynamic SQL is not really a terrific idea. Here is Erland
Sommarskog's page on dynamic SQL (a frequently referenced page):
http://www.sommarskog.se/dynamic_sql.html
I can't imagine why you'd actually want to do this. What are you trying
to achieve?
*mike hodgson*
blog: http://sqlnerd.blogspot.com
romy wrote:

>Hi
>Is it possible to return a table that its aliases are changing according to
>varaiables ?
>For example: I would like to use something like (ofcourse it doesn't work)
.
>
>declare @.p1,@.p2 varchar(30)
>set @.p1 ='blhablha'
>set @.p2 ='hghfg'
>select field1 as @.p1, field2 as @.p2 from table1
>
>|||rommy
if changing alias is only problem
you can use the trick of if condition in sp of CASE in query.Post your
script to suggest you better.
Regards
R.D
"romy" wrote:

> Hi
> Is it possible to return a table that its aliases are changing according t
o
> varaiables ?
> For example: I would like to use something like (ofcourse it doesn't work
).
>
> declare @.p1,@.p2 varchar(30)
> set @.p1 ='blhablha'
> set @.p2 ='hghfg'
> select field1 as @.p1, field2 as @.p2 from table1
>
>|||While I can't think of why you would need to do this on the server,
you could use put the results into a table, rename the columns
with sp_rename (which accepts parameters), then select the contents
of the table.
declare
@.cname1 sysname,
@.cname2 sysname
set @.cname1 = N'lName'
set @.cname2 = N'ID'
select LastName, EmployeeID
into #tmp
from Northwind..Employees
exec tempdb..sp_rename N'#tmp.LastName', @.cname1, 'COLUMN'
exec tempdb..sp_rename N'#tmp.EmployeeID', @.cname2, 'COLUMN'
select * from #tmp
drop table #tmp
Steve Kass
Drew University
romy wrote:

>Hi
>Is it possible to return a table that its aliases are changing according to
>varaiables ?
>For example: I would like to use something like (ofcourse it doesn't work)
.
>
>declare @.p1,@.p2 varchar(30)
>set @.p1 ='blhablha'
>set @.p2 ='hghfg'
>select field1 as @.p1, field2 as @.p2 from table1
>
>