Archives: March 2011

SQL Server Standard Reports Winforms

In SQL Server, there is a good set of preloaded reports to help you monitor the Instance.  These reports can be found under the Standard Reports and can be reached via context menu.  To find them, right click your Instance in Object Explorer from within SSMS.  Then navigate the context menu – much like the menus shown here.

You can see from the image that there is a decent amount of good reports available to choose.

When you run one of these reports, it is like a report that you would run from SSRS.  However, SSRS is not required to be installed in order to run these reports.

Occasionally, you may encounter an error when trying to run these reports.  The error that you may encounter is as follows:

The file ‘Microsoft.ReportViewer.WinForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a’ cannot be opened.

This error message seems to pop up commonly after an upgrade to SQL Server is performed (CU or SP).  Sometimes, it can crop up without an upgrade having been recently performed.

In the event that you encounter this particular error, you should try installing BIDS.  Though it is not necessarily a pre-requisite – it is a good idea to have it installed anyway and it also resolves this error message.

Another method that has worked for me to resolve this error is to install Microsoft Report Viewer 2008 SP1.

Additionally, besides looking into these Standard reports and hopefully helping you circumvent the aforementioned error, there is another recommendation.  In SQL 2005, there is a download for the Performance Dashboard Reports.  And in SQL 2008 there is a new feature called Management Data Warehouse.

You can download the Performance Reports from here.

You can see how to configure the Management Data Warehouse here.

Oh, and if you want to retrofit SQL 2008 with the 2005 Performance Dashboard, you will have to tweak it a bit.  You can read up on that here.

March 2011 S3OLV Meeting Recap

Categories: News, Professional, SSC
Comments: No Comments
Published on: March 15, 2011

The Las Vegas SQL Server Users Group met on March 10, 2011.  The meeting was both virtual and in-person.  Good news – we had just about as many person attending online as we did in the meeting room.

As I had announced, we had the pleasure of listening to Glenn Alan Berry.  Glenn spoke to us about many different tips around choosing hardware for better performance.  We heard about processors, memory, servers, and storage.  We ventured a little bit into virtualization and some recommendations if you are running virtual servers as well.

This is definitely one of those presentations people should check out.  The meeting was recorded and is available online for viewing over the next year.

You can view the presentation here.  You may need to enter some information to view the meeting, but the required information will pre-populate.

One last note:  to all those that attended the meeting -THANK YOU.  I also really appreciate those who have been willing to give presentations to this group over the past year since I have been scheduling speakers for the group.

DB Benchmarking

Comments: 3 Comments
Published on: March 14, 2011

As database professionals, we have a need to benchmark performance of the database, processes, and essentially overall performance.  When benchmarking, it is preferable to get a baseline and then run the same benchmark tests on a periodic basis and compare those results to the baseline.

Recently I was reminded of a couple of tools that should be in every DB Professionals vocabulary and tool set.  Each one is used for a different purpose.  Those tools are:

  1. CPU-Z
  2. TPC-E

CPU-Z is a freeware app that helps you gather information about motherboard, CPU, and memory.  It helps you to determine processor usage and if you are running your hardware at an optimal level.

TPC-E simulates the OLTP workload.  It is designed to be representative of OLTP systems and is scalable.

Both of these tools can be of great use to the database professional.  Check them out and see what you can learn by using them.

SQL Bitwise Operations

Tags: ,
Comments: 1 Comment
Published on: March 10, 2011

How many DB professionals have never had to deal with bitwise operations in SQL Server?  Who has never had a single value in the database represent more than one data value?  Have you ever had one of these fields serve as the(implicit or explicit) foreign key to a source table?

Sometimes it can seem a bit tricky dealing with such data – especially the last.  I’m not going to delve into the complexity of such scenarios.  I do want to present a basic intro however.

There are three basic operators for bitwise operations.  The operators are &, |, and ^.  These operators perform logical operations against integer type data.  Here is an example of what each would return when using the same values:

SELECT 175&75 AS BitAnd, 175|75 AS BitOr, 175^75 AS BitXOr
BitAnd	BitOr	BitXOr
11	239	228

When performing a Bit & operation, the bits in the result are set to 1 if and only if both bits (for the current bit being resolved) in the input expressions have a value of 1.  Any other combination results in a 0.

When performing a Bit | operation, the bits in the result are set to 1 if either of the corresponding bits is a 1.  A 0 is returned when both values are 0 in the corresponding bit.

When performing a Bit ^ operation, the bits in the result are set to a value of 1 if 1 of the two bits (but not both) has a value of 1.  Any other combination (either all 0s or all 1s) will result in a value of 0.

As I work with this a bit, I will be sharing a particular scenario that has been quite interesting for me.

Database Maintenance

Comments: No Comments
Published on: March 9, 2011

I often see a request for some scripts to help with database maintenance.  Sometimes those questions come in the form of recommendation requests for maintenance plans.  As many already know, there are some really good recommended scripts by Ola Hallengren.  There is also the fantastic index defrag script by Michelle Ufford.

Under normal circumstances, my recommendation would be that the maintenance of your database depends on your environment.  However, that doesn’t always work well.  Sometimes, something is needed quick to get up and in place while you figure things out in your environment and for your database (let’s say you just started a new job or you just inherited the database duties).

Under such circumstances, it would be good to have something ready to go already.  Thus, I recommend using these resources and learn from them.

Index Defrag Script by Michelle

Maintenance Scripts by Ola

T-SQL Tuesday #016: Aggregates and Statistics

Comments: No Comments
Published on: March 8, 2011

Data Size Collection and Analysis

By now you should be well acquainted with this phenomenon we call TSQL Tuesday.  This party is being hosted this month by Jes Schultz Borland (Twitter Blog).  She has challenged us to write something about aggregations and aggregation functions in SQL Server.

I stewed on this topic for a while trying to figure out something that would be relevant yet a little unique.  I think that is the real challenge – finding some application of the topic that may be somewhat unique or at least informative for somebody.

It dawned on me finally that I already have a topic in queue waiting to be written.  It was supposed to be a follow-up to my entry for last month.  (You can read that entry here.)  I concluded that entry with an admission that I hurried through the article to get it done in time.  Well, I was hoping to find the time to write the rest of my process – but now it fits quite well with this months theme.

Recap

Quickly, let’s recap what I did in that post and then I will proceed from there to tie this month to last month (as far as TSQL Tuesday goes).

In last months entry, I shared a script (an ugly one) that I created to cycle through all of the tables and columns of a database to get me some relevant data concerning the size of the data in my tables.  Well, actually I took a 2% sample of that information so I could run further statistical analysis.  The end goal was to have relevant data from an existing system and the R&D databases to create appropriate data sizes in the new database prior to releasing it to production.  With all of that data aggregated into a staging table, I was ready to being the next phase.

One thing I did not mention in that prior article was the creation of another table for this aggregation process.  I didn’t mention it because it used much the same process (though considerably faster because it didn’t do the same thing).   This table had a prime objective of collecting the max length of each column of each table of each database.  The structure is simple:

CREATE TABLE [dbo].[DataAnalysis](
	[DatabaseName] [sysname] NOT NULL,
	[TableName] [sysname] NOT NULL,
	[ColumnName] [sysname] NOT NULL,
	[MaxLength] [INT] NULL,
	[ColDataType] [VARCHAR](20) NULL,
	[MaxColLength] [INT] NULL
) ON [PRIMARY]

I mention this table now because I will be using it in my final aggregation.

Statistics and Aggregation

For my data analysis and trending, I wanted to find a simple distribution across quartiles.  A quartile is: One of the three numbers (values) that divide a range of data into four equal parts.  A quartile is used in statistical analysis and is commonly a part of a box plot.  Other statistical values that work well with the quartile include the MAX value.  Since I had usable data to be able to produce my quartile ranges, I used the following query to further aggregate and even used a function that provides the quartile.

SELECT DLA.DatabaseName,DLA.TableName,DLA.ColumnName, DA.ColDataType
	,DLA.ColLens,COUNT(DLA.ColLens) AS NumOccurence
	,CASE WHEN DA.MaxColLength = -1 THEN 2000000 ELSE DA.MaxColLength END AS MaxSupportedLen
	,DA.MaxLength AS MaxDataLen
    ,NTILE(4) OVER (partition BY DLA.DatabaseName,DLA.TableName,DLA.ColumnName ORDER BY DLA.ColLens) AS 'Quartile'
INTO DataStats
FROM DataLenStats_Alt DLA
	LEFT Outer Join DataAnalysis DA
		ON DLA.DatabaseName = DA.DatabaseName
		And DLA.TableName = DA.TableName
		And DLA.ColumnName = DA.ColumnName
	GROUP BY DLA.DatabaseName,DLA.TableName,DLA.ColumnName,DLA.ColLens,DA.MaxColLength,DA.MaxLength, DA.ColDataType
	ORDER BY DLA.DatabaseName,DLA.TableName,DLA.ColumnName,DLA.ColLens

From this script, you can see that I am taking data from the first two staging tables and dumping it into a third table.  With this query I am taking advantage of the NTILE() function that is available in SQL Server (2005 and up).  And since my data that has been accumulated is for more than one table, more than one database, and more than one column – I needed to partition that function based on those attributes.

With this data now available, I could see the trend of the data for any data field that may have been collected.  For instance, if I wanted to figure out the proper size (based on current data) of the phone number in my new database, I could now query the DataStats table like this:

SELECT * FROM DataStats DS
	 WHERE DS.ColumnName like '%phone'

I would then be able to determine where that field exists and the distribution of data across the quartiles and in comparison to the max data size for that field.  This helps to more intelligently assign a data size to fields based on existing data.  I could quickly ascertain that most of the data is within the second quartile (for instance) and that I have few outliers in the third and fourth quartiles and maybe an extreme case where the max is way out of scope in comparison.  At this point I could make an educated judgement call as to an appropriate size based on distribution, outliers and risk.

Conclusion

This exercise was a particularly challenging one.  It was challenging due to the desire to create quartiles for analysis.  I had wanted to break it down into Standard Deviations for further analysis (and still may).  This is highly useful when in the R&D or development phase.  I wouldn’t run the query from the first post on a production system because it is a long running process and can be resource intensive (I need to optimize it more).  This kind of script can really help to get better acquainted with the data as well.  I learned a lot by doing this and am looking forward to how I can improve upon it.

March SSSOLV Reminder

Tags: , ,
Comments: 1 Comment
Published on: March 7, 2011

This is just a quick reminder about the meeting coming up on March 10, 2011 at 6:30 PST.  You can find more information about the event from here.

I am looking forward to this presentation.  I think this presentation can be highly useful for both Production DBA as well as Development DBA.  Please join us Thursday evening to get some good information.  Anybody who wants to attend is welcome to attend – whether from Vegas or not.  (I will be attending afterall and currently do not live in Vegas.)

We will be recording the meeting and providing a link to it after the meeting.  So if you can’t make it, you may still be able to access it.

I hope to see you there (well, virtually anyway).

Having Cake and Eating it Two

Categories: News, SSC
Tags: , ,
Comments: 1 Comment
Published on: March 4, 2011

In early January, I wrote a little tribute to my wife for the awesome job she does when making cakes.  There was a lot of good feedback from that.  You can go back and read it from here, if you like.  This is a short follow-up to that article.  This is mostly because I think she has outdone herself again.

Just a short while ago was our oldest daughters birthday.  She just turned two.  Last year she got a ballerina music box as her birthday cake.  This year she got this:

I think she did a fantastic job on this.  The towers are all covered in colored white chocolate.  The cake was really tasty too!!

Here is another one from last year that didn’t make it onto the first article.  This is the tractor that was made for my niece.  This was another birthday cake.  We weren’t able to be there for the party (traveling back home at the time).  From what I hear though, people were impressed and my niece was quite happy with the cake.

This one was harder than one might think.  The hard part is getting the cake to stand off the ground and appear like the tractor is on wheels.  She was frustrated with it – but did a good job.

Re-purpose my TableSize Script

Comments: No Comments
Published on: March 3, 2011

Last Year I introduced a couple of scripts that I worked on.  Those scripts developed into a series covering the comparison of some methods and MS provided stored procs that could help you in the retrieval of table sizes in SQL Server.

I pulled out one of those scripts recently in order to find what tables, in an R and D database, were consuming alot of space.  While running that script, I realized that it could easily be used to help me with an additional task.  I decided that this script could help me deduce the top 10 biggest tables in a database that doesn’t necessarily need to have that data.  Or maybe, I just need to clean out the data so I can test populating the database.  This script is predicated on a lack of foreign keys – but can easily be adapted.

So, in all of its glory:

/*similar to sp_spaceused */
 
DECLARE @dbsize DECIMAL(19,2)
		,@logsize DECIMAL(19,2)
 
SET NOCOUNT ON
 
/*
**  Summary data.
*/
BEGIN
	SELECT @dbsize = SUM(CONVERT(DECIMAL(19,2),CASE WHEN type = 0 THEN SIZE ELSE 0 END)) * 8/1024
		, @logsize = SUM(CONVERT(DECIMAL(19,2),CASE WHEN type = 1 THEN SIZE ELSE 0 END)) * 8/1024
		FROM sys.database_files
 
END
/*
**  We want all objects.
*/
BEGIN
	WITH FirstPass AS (
		SELECT OBJECT_ID,
			ReservedPage = CONVERT(DECIMAL(19,2),SUM(reserved_page_count)) * 8/1024,
			UsedPage = CONVERT(DECIMAL(19,2),SUM(used_page_count)) *8/1024,
			PageCnt = SUM(
			CONVERT(DECIMAL(19,2),CASE
				WHEN (index_id < 2)
					THEN (used_page_count)
				ELSE lob_used_page_count + row_overflow_used_page_count
				END
			)) * 8/1024,
			RowCnt = SUM(
			CASE
				WHEN (index_id < 2)
					THEN row_count
				ELSE 0
			END
			)
		FROM sys.dm_db_partition_stats
		--Where OBJECTPROPERTY(OBJECT_ID,'IsMSShipped') = 0
		GROUP BY OBJECT_ID
	)
	,InternalTables AS (
		SELECT ps.OBJECT_ID,
			ReservedPage = CONVERT(DECIMAL(19,2),SUM(reserved_page_count)) * 8/1024,
			UsedPage = CONVERT(DECIMAL(19,2),SUM(used_page_count)) *8/1024
		FROM sys.dm_db_partition_stats  ps
			INNER Join sys.internal_tables it
				ON it.OBJECT_ID = ps.OBJECT_ID
				And it.internal_type IN (202,204,211,212,213,214,215,216)
		WHERE it.parent_id = ps.OBJECT_ID
			--And OBJECTPROPERTY(ps.OBJECT_ID,'IsMSShipped') = 0
		GROUP BY ps.OBJECT_ID
	)
SELECT 'Truncate table ' + OBJECT_NAME (f.OBJECT_ID) + '' AS TruncTabStatement
			,TableSizeMB = SUM(f.PageCnt) +
					SUM(CASE WHEN (f.UsedPage + IsNull(i.UsedPage,0)) > f.PageCnt
						THEN ((f.UsedPage + IsNull(i.UsedPage,0)) - f.PageCnt) ELSE 0 END)
	FROM FirstPass F
		LEFT Outer Join InternalTables i
			ON i.OBJECT_ID = f.OBJECT_ID
	WHERE OBJECTPROPERTY(f.OBJECT_ID,'IsMsShipped') = 0
	GROUP BY f.OBJECT_ID
	ORDER BY TableSizeMB DESC
 
END

I think the script, along with prior explanations, is pretty straight forward.  This can quickly help reset those LARGE tables for continued testing.  Of course, that is predicated on you not already having a script for that, and that you don’t know what tables need to be reset (maybe you are in a large team).

This is just one example of a script that can be useful for more than what it was first designed to do.  As DB professionals, we often come across situations were a prior script can easily be repurposed for the task at hand.  Knowing that, and how to do it, is an important tool in your toolbox.

S3OLV March 2011

Tags: , ,
Comments: No Comments
Published on: March 2, 2011

The Ides of March are upon us and that means that we have another opportunity to learn some stuff about SQL Server.  We have that opportunity because it is time for the monthly S3OLV User Group meeting.

This month, Glenn Berry of SQL Server MVP fame has volunteered to present to our group via Livemeeting.  Glenn will be teaching us how to properly Select and Size database hardware in regards to OLTP performance.  Here is the abstract for this presentation.

The foundation of database performance is the underlying server hardware and storage subsystem. Even the best designed and optimized database application can be crippled by an inadequate hardware and storage infrastructure. Recent advances in new processors and chipsets, along with improvements in magnetic and SSD storage have dramatically changed the evaluation and selection process compared to the past. Many database professionals struggle to keep up with new technology and often simply let someone else make their hardware selection and sizing decisions. Unfortunately, the DBA usually gets the blame for any performance issues that crop up later. Don’t let this happen to you! This session covers current and upcoming hardware from both Intel and AMD and gives you the tools and resources to make better hardware selection decisions to support SQL Server OLTP workloads.

Details

We will be holding this learning opportunity March 10, 2011 between 6:30 PM PST and 8:30PST.

Livemeeting Connection Information can be found as follows:

  • Copy this address and paste it into your web browser: https://www.livemeeting.com/cc/UserGroups/join
  • Copy and paste the required information: Meeting ID: 3DPBZQ
  • A little about our Presenter

    Glenn works as a Database Architect at NewsGator Technologies in Denver, CO. He is a SQL Server MVP, and he has a whole collection of Microsoft certifications, including MCITP, MCDBA, MCSE, MCSD, MCAD, and MCTS, which proves that he likes to take tests. His expertise includes DMVs, high availability, hardware selection, full text search, and SQL Azure.  He is also an Adjunct Faculty member at University College – University of Denver, where has been teaching since 2000. He recently completed the Master Teacher Program at Denver University – University College. He is the author of two chapters in the book SQL Server MVP Deep Dives, and blogs regularly at http://sqlserverperformance.wordpress.com.

    Contact Info
    http://sqlserverperformance.wordpress.com
    http://www.linkedin.com/pub/glenn-berry/10/a61/6b8
    Twitter: GlennAlanBerry

    «page 2 of 3»
    Calendar
    March 2011
    M T W T F S S
    « Feb   Apr »
     123456
    78910111213
    14151617181920
    21222324252627
    28293031  
    Follow me on Google+

    In 0 people's circles

    Add to circlesi
    Content
    Categories

    Categories

    Now Reading

    Now Reading

    Planned books:

    Current books:

    • ChiRunning: A Revolutionary Approach to Effortless, Injury-Free Running

      ChiRunning: A Revolutionary Approach to Effortless, Injury-Free Running by Danny Dreyer, Katherine Dreyer

    • Advanced Marathoning – 2nd Edition

      Advanced Marathoning – 2nd Edition by Peter Pfitzinger, Scott Douglas

    • SQL Server MVP Deep Dives

      SQL Server MVP Deep Dives by Nielsen Paul, Delaney Kalen, Machanic Adam, Tripp Kimberly, Randal Paul, Low Greg

    • A World Without Heroes (Beyonders)

      A World Without Heroes (Beyonders) by Brandon Mull

    Recent books:

    View full Library

    SQLHelp

    SQLHelp


    Welcome , today is Thursday, May 17, 2012