473,385 Members | 1,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Rotating information from Recordsets to columns.

Tim
Hello,

This problem perplexes me and I hope that someone has done something
efficient.

Take for example the data in the MASTER..SYSPERFINFO:
SELECT
CAST(RTRIM(INSTANCE_NAME) AS VARCHAR(15)),
CAST(RTRIM(COUNTER_NAME) AS VARCHAR(31)),
CAST(RTRIM(CNTR_VALUE) AS VARCHAR(10))
FROM MASTER..SYSPERFINFO
WHERE INSTANCE_NAME = N'TEMPDB'

tempdb Data File(s) Size (KB) 51200
tempdb Log File(s) Size (KB) 1272
tempdb Log File(s) Used Size (KB) 738
tempdb Percent Log Used 58
tempdb Active Transactions 0
tempdb Transactions/sec 186281
tempdb Repl. Pending Xacts 0
tempdb Repl. Trans. Rate 0
tempdb Log Cache Reads/sec 0
tempdb Log Cache Hit Ratio 0
tempdb Log Cache Hit Ratio Base 0
tempdb Bulk Copy Rows/sec 0
tempdb Bulk Copy Throughput/sec 0
tempdb Backup/Restore Throughput/sec 0
tempdb DBCC Logical Scan Bytes/sec 0
tempdb Shrink Data Movement Bytes/sec 0
tempdb Log Flushes/sec 1578
tempdb Log Bytes Flushed/sec 67882496
tempdb Log Flush Waits/sec 226
tempdb Log Flush Wait Time 47
tempdb Log Truncations 248
tempdb Log Growths 3
tempdb Log Shrinks 0

<I did the CAST and LTRIM so that it looks better when displayed in a
browser>

I would like to keep statistics in a table with the following columns:
INSTANCE_NAME,
DATA_FILE_SIZE,
LOG_FILE_FIZE,
ACTIVE_TRANS,
TRANS_PER_SEC
So, instead of having a table with three columns and 23 rows(only 4 of
which I want), I would have a single row with 4 columns(plus the
Instance_Name).

Visualy, I want to call this a 90 degree rotation. Here's what the
select statement would then look like:
SELECT *
FROM SYSPERFINFO_ARCHIVE
WHERE INSTANCE_NAME = N'TEMPDB'

Here's the result set:
tempdb 51200 1272 0 185198

Is it possible to 'rotate' a recordset into columns?
How would it be done?

Gracias.
Jul 20 '05 #1
2 5548
Tim (go**************@cfapostle.com) writes:
So, instead of having a table with three columns and 23 rows(only 4 of
which I want), I would have a single row with 4 columns(plus the
Instance_Name).

Visualy, I want to call this a 90 degree rotation. Here's what the
select statement would then look like:
SELECT *
FROM SYSPERFINFO_ARCHIVE
WHERE INSTANCE_NAME = N'TEMPDB'

Here's the result set:
tempdb 51200 1272 0 185198

select a.instance_name,
data_file_size = a.cntr_value,
log_file_size = b.cntr_value,
active_trans = c.cntr_value,
trans_per_sec = d.cntr_value
from master..sysperfinfo a
join master..sysperfinfo b on a.instance_name = b.instance_name
join master..sysperfinfo c on a.instance_name = c.instance_name
join master..sysperfinfo d on a.instance_name = d.instance_name
where a.instance_name = N'tempdb'
and a.counter_name = N'Data File(s) Size (KB)'
and b.counter_name = N'Log File(s) Size (KB)'
and c.counter_name = N'Active Transactions'
and d.counter_name = N'Transactions/sec'
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
Erland Sommarskog <so****@algonet.se> wrote in message

select a.instance_name,
data_file_size = a.cntr_value,
log_file_size = b.cntr_value,
active_trans = c.cntr_value,
trans_per_sec = d.cntr_value
from master..sysperfinfo a
join master..sysperfinfo b on a.instance_name = b.instance_name
join master..sysperfinfo c on a.instance_name = c.instance_name
join master..sysperfinfo d on a.instance_name = d.instance_name
where a.instance_name = N'tempdb'
and a.counter_name = N'Data File(s) Size (KB)'
and b.counter_name = N'Log File(s) Size (KB)'
and c.counter_name = N'Active Transactions'
and d.counter_name = N'Transactions/sec'


Wow!. There are times I feel like a complete newbie. Hats off to the
set based thinkers as opposed to us poor old procedural bods.
Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Steve Marciniak | last post by:
I'm trying to display different recordsets (which are 1 field each) as columns right next to one another. For example, Recordset1 is displayed on the left hand side of the screen. Recordset2 is...
31
by: Royal Denning | last post by:
I am designing a table with 2 columns and 20 rows. I want to insert small images (each with a link) and a text title in each cell of the table. On refresh of the page, I would like to have the...
22
by: James Cane | last post by:
Here's an interesting problem that someone might have an answer to... Some time ago, I wrote a set of utility classes which wrap up the custom row source function needed to add arbitrary items to...
0
by: B | last post by:
Using Access2000, the sample code below is what I have been modifying and working on since the past week and I could not get it to work properly. What I wanted to accomplish: 1) read from a...
4
by: Roozbeh GHolizadeh | last post by:
Hi there... i think it is a very common problem but i dont know why i didnt find anything good for me on internet... i want to simply rotate an array with 90,180,270 degrees.... here is how...
16
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and...
3
by: avalence | last post by:
Hello, I am trying to create a nice rotating earth globe (on mouse) on my web site, in order to display my professional relationships all over the world. The best way seems to be a javascript. In...
1
by: AR123 | last post by:
Hi I want to set up a rotating banner. Not sure how to incorporate my rotating banner code into the code below. I want the rotating banner to be the main feature image? This is set up in...
1
kmartinenko
by: kmartinenko | last post by:
I have a table with over 12,000 entries. I have created a form (with the help of this forum) that will return the search results based upon the stop and stop time selected. See post...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.