显示标签为“similar”的博文。显示所有博文
显示标签为“similar”的博文。显示所有博文

2012年3月29日星期四

Disk usage Report

There needs to be two levels of disk usage reports, one that just reads the meta data (similar to 2000 functionality), and displays the pretty graphs, and then the one that is currently available that does the index analysis and so on. I have a 1.2 TB database on 2005 and it takes forever to pull up that report (which my client has decided they love)...

Also, I do not know how hard it would be to keep a running analysis of database/index fragmentation, but that would be a nice feature also, even if it was an enterprise only feature.

Just a thought.

Hi Jake,

Thanks for the feedback. I'll pass it along to the PM who owns the reports in SSMS.

Cheers,
Dan

2012年3月19日星期一

Discarding an empty result set in a stored proc

I have a stored proc with code similar to this:
<SQL Query 1 Here>
If @.@.RowCount < 1
Begin
<SQL Query 2 Here>
End
Basically, I want to execute SQL Query 1 and if I don't get any rows,
then execute Query 2. What happens here is that I get two result sets
returned if the first one is empty. I changed my query to this:
Declare @.RecCount int
Select @.RecCount = <SQL Query 1 Here>
If @.RecCount > 0
Begin
<SQL Query 1 Here>
End
Else
Begin
<SQL Query 2 Here>
End
This way, I only get one result set, but I am wondering about
duplicating Query 1 and if that incurs a performance penalty. If so,
how can I get rid of it.
The queries themselves are simple queries that query one table with no
joins or anything else in them.
Any thoughts on this approach? Is there a 'more elegant' way of
accomplishing what I want?
Thanks,
ChrisI would do it like this
If exists (select * from table1 where ...)
Begin
select * from table1 where ...
End
Else
Begin
select * from table2 where ...
End
http://sqlservercode.blogspot.com/|||> What happens here is that I get two result sets
> returned if the first one is empty.
So? Isn't the client smart enough to see that resultset 1 is empty, and
move to the next one? In ADO, you would check for recordset.eof.
Another idea would be to do a UNION, if the resultsets are similar. If the
resultsets are not similar, then the client is going to have to perform some
logic based on which query was successful, no?
A