Archives: November 2011

SQLInspire NYC 2011

Categories: News, Professional, SSC
Tags:
Comments: 2 Comments
Published on: November 14, 2011

I sit here in a hotel room as I reminisce on this past weekend.  This last weekend began with a red-eye trip from Salt Lake to New York.  The reason for taking that trip was merely to attend SQLInspire – oh and to support the community.

This event was organized by a friend and some of his friends (whom I got to finally meet this weekend).  That friend is Robert Pearl.  Some of his friends (until now were my online acquaintances) include Mike Coles, Brian Moran, Andy Leonard, Melissa Demsak and Matt Velic.  I also had the chance to meet Tom LaRock and re-meet Steve Jones.

The premise of the event is to Inspire Database professionals to continue in the field or improve in the field in some way.  Due to that premise, there was very little tech talk.  Which is probably a good thing because I was having a hard enough time staying awake ;) .

I could talk about all of the talks, but I want to recap just one of the talks and then discuss something entirely different for a bit.

The one talk that I found really moving was by Tom LaRock (whose daughter bears the same name as my oldest daughter).  His talk was titled “Someday.”  And for most of the talk you could see me  largely agreeing to what he was saying.  In short, there are “Somedays” that are more important than others.  Don’t be too caught up to let those pass you by.  A “Someday” with your children is far more important than that email you are sending.  Don’t get too caught up that you are passing by what you value most and where you would like to be (re: goals).  The smart alek in me really wanted to ask him during Q&A how to get on his blogroll.  Purely because of a comment he made on his last Rankings update about James Serra (Oct 3, 2011).

Outside of the speeches, there was another thing that was both entertaining and inspirational.  Despite the best efforts of the organizers, it seemed that Halloweem, NYC or something was conspiring against them to make things go awry.  From a computer glitch that caused the attendee list to disappear from the security system, to late arriving donuts, to white-screens raising and lowering throughout Bobby Tables’ presentation and little things like that; it seemed the event was destined for problems.

Not missing a beat though, those issues just kept getting corrected (it’s what DBAs do anyway).  Had I known about this dude though – I might have avoided the event.  OK, I would have just avoided visiting Times Square after 5PM.

Last words:  This event was also to help people network.  Networking time was built into the schedule.  Very good move Robert, Brian, Andy and Gang!!

T-SQL Tuesday #024: Prox ‘n’ Funx

Comments: No Comments
Published on: November 8, 2011

I find myself just now sitting down to write this as the deadline for TSQL Tuesday 24 fast approaches.  Fortunately I started planning out what I wanted to cover several days ago.

I could have tried writing this last night – but I ended up falling asleep at the keyboard.  Drowsy typing can be a very dangerous thing.  So it is a good thing I didn’t start then.

Alas, I digress.  This month, a TSQL guru (BRAD SCHULZ), is at the helm.  He has challenged us to write about procs and functions.  We get decide which direction we take it.

I thought about this and figured there could be a few functions and paths to take on this.  So let’s get started and see where this bird-walk can take us.

Function for which I am thankful

I decided that this is a topic that must be discussed.  It is the month of Thanksgiving afterall.

For this topic, I want to give a shout out to Jeff Moden for a function that he wrote about and published.  This function has proved useful to solve some performance issues.

In a recent case where this function helped, I was a bit reluctant because it just didn’t seem possible that the function already in place could have that big of an impact.  Guess what, it did.  The function that Jeff did was his string splitter.  The strings in question were short and each value was not very big.  Despite that, the string splitter was chewing up resources.

After implementing the new string splitter, we saw immediate performance gains.  Using this function has paid off big dividends and has saved me a grundle of time.  With time being more valuable as time passes, I am very thankful to Jeff for the work he did on his function.

Function I can’t live without

That might be overstating it a bit.  The reality is, there are some functions that I use far more in my scripting and troubleshooting than others.  One function, above all others, seems to come into use more frequently.

This function is a dynamic management object and is called dm_db_index_physical_stats.  There are several parameters to this function and there are several uses for it as I have seen and demonstrated on my blog.

To learn more on the parameters, read this.  As MSDN states, this function “Returns size and fragmentation information for the data and indexes of the specified table or view.”  So you can ascertain quickly that the most likely use of this index is in index fragmentation analysis.

I have written about this function for index analysis, table size analysis, BLOB index analysis, and finding ghost records.  I even referenced it when doing a table compression analysis.

You can check out all of those articles here.

There is just so much good info that can be gleamed from this function and so many ways to use it.  That is why I find myself coming back to it time and time again.

Funcs for Fun

There are many functions that are useful.  Some are more interesting than others.  Some, I use because I find it fun delving into the internals of SQL Server.  If the function can provide useful information and I learn something along the way, then it is pretty fun.

Here are some of those functions that I have enjoyed using.

sys.fn_physloccracker

sys.fn_virtualfilestats

sys.dm_exec_query_plan

sys.dm_exec_sql_text

sys.dm_io_virtual_file_stats

You can find good information on most of these in MSDN.  For sys.fn_physloccracker, you may want to rely on this from Paul Randal.  You can even read what little I wrote about it a few months ago.  I came across this little function while working on a pet project (that I still need to finish – d’oh).

Conclusion

Functions are very handy.  They can also prove to be the cause of poor performance (such as was the case with that string splitter).  When used appropriately, you can provide well-performing SQL as well as some very handy information.

SSSOLV November 2011 Meeting

Tags: , ,
Comments: No Comments
Published on: November 7, 2011

Another month, another meeting.  Time really is flying.  And now with more Holidays fast approaching, I am sure that time will warp on us.

The Las Vegas user group is happy to announce that we have a new topic and new presenter (new to us anyway) for the month of November.  Norm Kelm is prepared to teach us a few things about his new hammer.

POWERSHELL, THE NEW SQL HAMMER

You’ve seen all the amazing scripts that use PowerShell, but writing your own is raising more questions. This session will help fill in the gaps by explaining all the moving parts of PowerShell 2.0, the integration with SQL Server and answer the following questions as well as others. Why is Invoke-Sqlcmd necessary? What is and why is there a Minishell for SQL Server? What makes the SQLSERVER: PS Drive so powerful? How does a remote SQL Server get added to the SQLSERVER: PS Drive?

Norms Bio

Norman Kelm is the owner of Gerasus Software, http://www.gerasus.com/, the maker of SSIS-DTS Package Search the only utility that can search SSIS and DTS packages. Norman has been working in IT for over 20 years. He worked as a FORTRAN and C developer for 8 years before making the jump to databases with Sybase. He then moved on to SQL Server working as a production and development DBA on SQL Server since version 6.5. He is also a founding member of the Tampa Bay SQL Server User Group.

We welcome all to attend (as we do every month).  Here is the online meeting information:

LiveMeeting Information:
 Attendee URL:  https://www.livemeeting.com/cc/UserGroups/join?id=2JK8TZ&role=attend
 Meeting ID:  2JK8TZ
In Person Attendees:
The meeting location has changed.  We will no longer be meeting at The Learning Center.  New meeting location is M Staff Solutions & Training / 2620 Regatta Drive Suite 102 Las Vegas, NV 89128.

We are Family

Categories: News, Professional, SSC
Tags: ,
Comments: No Comments
Published on: November 7, 2011

It has been a while since I last wrote something for a meme monday.  This month is a perfect time to jump back in the deep end.

If you don’t know what a meme monday is, then here is a little recap.  Thomas LaRock started this to assist in getting the blog writing juices flowing.  He provides a simple, usually open ended topic.  As with most memes, you should write something if you get “tagged,” but you can participate without the tag.  In fact, I usually forget to tag somebody and have yet to be tagged (to my knowledge anyway).

This month, the topic is SQL Family.

SQL Family

What is the SQL Family?  Well, loosely stated I think of a family as a close knit group of individuals working together with common goals and helping each other – a lot.

How does that translate to the SQL Family?  The SQL Family is very big from my point of view.  I have blogged a few times about this family.  You will usually see me referring to this family as community.

What does this SQL Family do for you and me?  A LOT!!!  Here are some of the things I know that this group of people does for you and me.

Support – Have you ever experienced something that is not SQL related?  This group of individuals will lend a hand, shoulder, limb or what is needed in many circumstances.  From bullying to death to divorce to a hospitalized child at one end of the spectrum to marriage, child birth, awards and recognition at the other end.  This group will be there for you.

Train – what other group of professionals regularly gives of time and money to train and teach you every weekend – somewhere/somehow?  It’s not just the training on the weekends – it goes far deeper than that.  Many write books on the topic of SQL.  And these people make themselves available to train via twitter, forums, email, and in person.  Granted, not all of this training is free – but there is a ton of it that is free.

Help – Have you heard of the twitter hashtag #sqlhelp?  How about the msdn forums?  Have you heard of SQLServerCentral?  How about Stackoverflow?  There are so many people giving of their time to help other database people get better at what they do.  On the other side of the coin, the family is also there to help proof read and tech edit articles and books.  Not to mention that they often times find themselves helping by lending a professional opinion from anything SQL related at work to professional behavior in the workplace.

Fraternize – The SQL family, like most families, is not all work all the time.  There is a lot of play, chit chat and hanging out going on in this group.  This comes in real handy when you are out of town – in a place you don’t know too well.  There is plenty of joking as these people become friends.  There is a level of trust and respect that is gained.  So much so that these people will jump to your side quickly to defend you – just as you would do for your little sister or brother.

Network – Have you ever been in need of a break?  Maybe just a way to get to that next job?  The network that comes with this family is pretty vast.  You will have exposure to many more opportunities than you might have expected looking on your own.

These are all benefits of the SQL Family.  I have talked a lot about what they do for you.  As with good families, it goes both ways.  It’s not required for you to do all of these things.  But, once you start seeing what has been done for you – it is very hard to not reciprocate in some way.  The more everybody contributes, the stronger this family becomes.  Not only does the family become stronger – but you gain and grow far more than a) without the family and b) just leaching from the family.

Another Color Wheel

Categories: News, Professional, SSC
Tags: ,
Comments: No Comments
Published on: November 3, 2011

Some time ago, I had the opportunity to work on a problem involving the color wheel.  The requirements for that problem lent themselves to a solution involving bitwise operations (which you can read here).

I recently came across a new problem involving the color wheel.  This time the requirements and solution are different than the last.  So what better opportunity than the present to write about it.

This time we are presented with a variation where we have been introduced to a group.  The group has various colors.  Given a group, I need to find the other groups that contain a color that the given group does not contain.

Frankly, the solution to this problem is far easier than I initially set out to make it.  Memory being as it is, I did the same thing with the Color Wheel the last time.  I had to revisit that one and update that solution.

This time around, I have simplified the solution prior to writing about it.  That said, somebody will probably show me an easier way to solve it. ;)

Setup

Here is the table with the data that we will be using.

Groups Colors Numbers
A RED 1
A GREEN 2
A BLUE 3
B RED 1
B YELLOW 4
C BLUE 3

Solution

I elected to utilize a CTE rather than formalize a table for the extraction of this sample.  The following solution will thus be using that CTE rather than a table.

DECLARE @startgroup CHAR(1) = 'B'
;
WITH colorwheel (Groups,Colors,Numbers) AS (
SELECT 'A', 'RED', 1
UNION ALL
SELECT 'A', 'GREEN', 2
UNION ALL
SELECT 'A', 'BLUE', 3
UNION ALL
SELECT 'B', 'RED', 1
UNION ALL
SELECT 'B', 'YELLOW', 4
UNION ALL
SELECT 'C', 'BLUE', 3
)
 
SELECT Groups,COLORS, cw.NUMBERS
	FROM colorwheel cw
	WHERE cw.Numbers NOT IN (SELECT Numbers FROM colorwheel WHERE Groups = @startgroup)

Notice the use of a subquery.  This subquery represents a derived table of Color IDs (since the Numbers column is representative of IDs of the colors).  This is the set of data we want to compare against.  If the color is in this derived table, then we do not want that data in our final result set.

With this setup, I can change the group via the @startgroup variable.  I can now meet the criteria thanks to the “NOT IN” and only produce those groups and color combinations that do not exist in the provided group/starting group.

See, it really is not too difficult.  Breaking down what the requirements are, we can simplify the query and produce the desired results.

Quick and Dirty Index Info

Categories: News, Professional, Scripts, SSC
Tags: ,
Comments: No Comments
Published on: November 1, 2011

From time to time, somebody needs to find some information about the indexes in the database.  As DBA’s, there are a few tools at your disposal to look up that information.  The required/requested information is not always the same.  That said, you can usually adapt a query quickly to find what you need.

Where to Look

SQL 2005 and up have provided us with some very useful means to gain insight into the indexes in our databases.  The following DMOs is a small representation of that information.

  • sys.dm_db_missing_index_details
  • sys.dm_db_missing_index_group_stats
  • sys.dm_db_missing_index_groups
  • sys.dm_db_index_usage_stats
  • sys.dm_db_index_physical_stats

Add to that, there are some catalog views to help with finding information relevant to indexes in the databases.

  • sys.indexes
  • sys.index_columns

With just these few objects, there is a wealth of information at your fingertips.  I often find myself querying for information about indexes.  I also find myself being asked how to find this information on a relatively frequent interval.  Usually, I just end up writing out the query again (depends on mood and day).

Rewriting the query doesn’t take too much time when you know what you need to query.  That said, sometimes it is nice to have a base query ready to go.  From this query you can add/remove items as you see fit to get the information that you really need.

For instance, here is a query to get some of the fragmentation information.  I would probably just re-use this query over and over where applicable – only changing the parts that mattered to get the necessary result set.

SELECT OBJECT_NAME(ps.OBJECT_ID),I.name,index_level,index_type_desc
		,I.is_hypothetical,ps.page_count,ps.record_count,ps.avg_fragmentation_in_percent
		,ps.ghost_record_count
		,ps.compressed_page_count
	FROM sys.dm_db_index_physical_stats(DB_ID(),null,null,null,'detailed') ps
		INNER Join sys.indexes I
			ON ps.OBJECT_ID = I.OBJECT_ID
			And ps.index_id = I.index_id
	ORDER BY OBJECT_NAME(ps.OBJECT_ID),ps.index_id,ps.index_level

There are many types of queries we could write for the different relevant information pertaining to our indexes.  It is all a matter of knowing where to start.  I hope that knowing about these DMOs and catalog views, it will help shorten your efforts to retrieving this information.

«page 2 of 2
Calendar
November 2011
M T W T F S S
« Oct   Dec »
 123456
78910111213
14151617181920
21222324252627
282930  
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