Re: Complex query question



Check this dynamic pivoting T-SQL solution:
http://weblogs.sqlteam.com/jeffs/articles/5120.aspx.

--
Dejan Sarka
http://www.solidqualitylearning.com/blogs/

"Waterboy" <Waterboy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:73C78A9C-D882-4FE2-9683-B76F7B54C287@xxxxxxxxxxxxxxxx
Hello all,

I have a stored proc that grabs a lot of data (4520) rows per day. I need
to
pivot the data but the columns are not the same everytime its ran, it
depends
on the asset i have selected. i need to covert the data to a csv file,
which
im currently doing in the presentation side, but the data is so large that
looping through it is eating ram up like crazy. so i would like to shift
the
data using sql

Currently the data comes back like this...
___________________________________________________________
Tag | DataValue | Time | Name | Site
|
-----------------------------------------------------------------------------------
st_act_air | 230.3 | 15:00 | Petyo 123 | Peyto
|
st_act_fuel | 72.5 | 15.00 | Petyo 123 |
Peyto
|
------------------------------------------------------------------------------------


I need the data to come back like this:
_________________________________________________________
Site | Name | Time | st_act_air |
st_act_fuel
|
---------------------------------------------------------------------------------
Peyto | Peyto 123 | 15:00 | 230.3 | 72.5
|
--------------------------------------------------------------------------------

im using sql server 2000, any one have any ideas or suggestions?



.



Relevant Pages

  • Re: Complex query question
    ... "Dejan Sarka" wrote: ... I have a stored proc that grabs a lot of data rows per day. ... pivot the data but the columns are not the same everytime its ran, ... im using sql server 2000, any one have any ideas or suggestions? ...
    (microsoft.public.sqlserver.datamining)
  • handling errors from stored procs
    ... SQL Server 2000 ... comprise the call to a stored proc ... the stored proc gets run...if so, it would be nice if the Access app ... - when stored proc encounters error, it returns that error message ...
    (comp.databases.ms-access)
  • Re: Retrieve error text from extended stored proc
    ... was only on first execution, the following executions, error number was 0. ... However, use OSQL with the -m-1 switch, and you will see that the RAISERROR ... Tibor Karaszi, SQL Server MVP ... > When I call the stored proc from Query Analyzer and force an error, ...
    (microsoft.public.sqlserver.programming)
  • Re: best way to retrieve thousands of records.
    ... I understand you should have a chunky not chatty interface, ... i.e code up another stored proc that accepts ... > retrieve records from sql server. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: best way to retrieve thousands of records.
    ... I understand you should have a chunky not chatty interface, ... i.e code up another stored proc that accepts ... > retrieve records from sql server. ...
    (microsoft.public.dotnet.framework.adonet)

Loading