Thursday, April 14, 2011

Don't Be Afraid, Not Being The Smartest Person In The Room

"I don't have to be the smartest person in the room". I once didn't take a job because of this phrase.  It was probably one of the best things that ever happened to me and it worked out quite well for a friend of mine.  But I'm getting ahead of myself, let me tell the story from the beginning.

DON'T BE AFRAID

A little philosophy first.  I'm not going to go Ayn Rand or Immanuel Kant on you, but as Louis Davidson (Blog|Twitter) would say, "We're drinking my flavor of Kool-AID today.

I don't have to be the smartest person in the room.  I don't, just don't need to.  Sometimes you will be, sometimes you won't.  If you don't worry about it, then it takes a lot of pressure and stress off.

"But Balls", you say, "Why are you afraid of being smart!?"

Ahh but that's just it Dear Reader, I'm not Afraid.

We've all been in the room with someone that THINKS they know everything.  We've all worked with someone, that just always had to be right.  Have you ever worked with someone like this on the day they were wrong?  

I have a better question would you want to be them on the day they are proven wrong?  No I wouldn't either.  If you always HAVE to be right, then being wrong is a crushing blow.

People can be afraid of a lot of things.  They can let themselves be ruled by fear, fear that your boss won't listen, fear that you don't know as much as the guy sitting next to you, Fear of Not Being the Smartest Person in the room.

I've seen this back fire on so many people that I've always wanted to take a different approach.  I find that you never know where the best idea will come from on a team.  It could be the developer that has been written off as lazy, that has a great out of the box idea.  It could be the obnoxious DBA that has some insight into the best way to layout a project's architecture.  It could be a Server Engineer that has really good insight on code management and migration.

If you make yourself open to the possibility that everyone has something to contribute, then you don't close yourself off to ideas.  And again you take a lot of weight off of your shoulders.


ROOM TO GROW AND STRETCH

A couple jobs ago I was looking for a new position.  I had reached what I felt was a ceiling.  I had been a Sr. Developer, mentored others, gotten my SQL Certifications, and filled the roles of a Sr. DBA & Sr. Developer.  I had worked on some cool projects, and really loved the people I had worked with.  

However, I wanted to grow and we were a very top heavy team.  A lot of people had been with the company for years, many had their Masters in IT or MBA's, MCAD's, and MCSE's brilliant people that I'm still very happy to call friends.  But with a great experienced group the only way to move into the full time job I wanted was for someone to leave.

HE'S NOT THE MIZ BUT HE'S AWESOME!

So I struck out to find greener pastures.  One particular job had advertised itself as Sr. DBA position.  I applied, and found that the person leaving the job was Awesome.  The company hated to loose Awesome, the client that Awesome served was thrilled with them, and Awesome had no desire to go but was moving to follow his wife's career.

We met several times over a month, and I went on-sight to meet the client.  The more I learned about the position, the more it didn't feel like a good fit.  I found that the only reason they wanted a DBA and were requiring an MCITP for SQL was because Awesome had that and they wanted Awesome II.  It was more of an Analyst/Team Lead position.

While meeting the client, I was asked to explain how I would describe myself as a Manger.  And I said "I'm not afraid, not to be the smartest person in the room.  I think everyone brings something to the table, I like to listen, I like to consider what the boots on the ground have to say, I don't think that my position entitles me to ideas that are more brilliant than anyone else, and as a Manager I'm not afraid to cheer someone on who's smarter than I am in a subject.  If I find someone smarter than I am, I want to learn from them, so I can be as educated as possible on the subject at hand."

I'M THE BEST AT WHAT I DO EVEN THOUGH WHAT I DO ISN'T VERY NICE IS BE A DBA


To be honest I thought it was a pretty good answer, and I'm still satisfied with it.  When we left the client site, the person who would have been my future manager, tore into me. 

I believe the coversation started out with "I DON'T KNOW WHAT IN THE HELL THAT SHUCK'S GOOD OLD BOY, HUMBLE CRAP WAS......" Needless to say I was taken back.   But I stuck to my guns, which probably only served to enrich the colorful nature of the rest of our conversation.  

The remainder of the conversation centered on how I always, ALWAYS, needed to be the smartest person in the room.  As I explained a little earlier, this flies in the face of how I work.  You can take a job where you compromise yourself, but I can't see how you can do that and be happy.


I told my wife later, that had I already taken the job the tone of the conversation would have left me worried that I would have been fired.  We talked about it that evening, and even though it would have been a significant raise, SIGNIFICANT RAISE, I asked if she would be alright with me passing.  My very wise and beautiful wife replied by saying that she didn't know why I was still even considering it.

IT ALL WORKED OUT

The day before I decided to pass a brilliant friend of mine, Perfect, found themselves without a job.  When I had worked with Perfect previously, Perfect had been an Analyst that had been a Team Lead over Developers, and was a perfect for this job.

I got Perfect's resume, and called and informed the recruiter I had been dealing with that I wouldn't be taking the job replacing Awesome.  Despite protests, I told them it may not seem like it, but I've got a person for this job whose Perfect.  I didn't have any hard feelings.  I wasn't the right person, and they weren't the right fit for me.  But I was going to send them Perfect's resume, and they should set up a meeting as soon as possible.

Perfect still works there, Perfect loves their job and is very successful.  And me, I found a little job up in D.C. working for the President, that led me to the Great State of Florida where I was very happy to land.

I guess my only parting advice Dear Reader would be don't be afraid of a someone who is smarter than you.  Embrace them, learn from them, and work hard.  At the end of the day how can anybody be unhappy with learning something new, and making themselves better.

Thanks,

Brad

  

Tuesday, April 12, 2011

T-SQL Tuesday 17: Apply

Welcome to another T-SQL Tuesday!  This week is hosted by Matt Velic (blog|twitter), so Matt what is this week about?
APPLY Knowledge
Recently on Twitter, I heard the claim that “If you don’t understand the APPLY operator, your skills are somewhere around the 50th percentile at best.” While I believe that Adam was giving a warning to self-proclaimed experts (possibly one he might have been interviewing at the time…), I also believe that we could take it as a challenge as a T-SQL blogging community to learn more about APPLY and the ways in which we can use it in our work.
Please share how you use this wonderful feature. Maybe you know how APPLY works inside and out? Perhaps you’ve got a fantastic user defined function (UDF) to share? Or maybe your experience revolves around using Dynamic Management Functions (DMFs) in your never-ending quest for SQL Server performance? Let the community know as it is time to study!
All right, here we go then this is all about the Apply!

START WITH THE BASICS

The Apply operator was added to SQL Server with SQL 2005.  Apply  is a logical join operator, it allows you to perform a join on a Table Valued Function.  I think the most common way that people use Apply is to get the SQL Text or Query Plan using DMV’s.

SELECT
    er.session_id
    ,st.text
    ,qp.query_plan
FROM sys.dm_exec_requests er
CROSS APPLY sys.dm_exec_sql_text(er.plan_handle) st
CROSS APPLY sys.dm_exec_query_plan(er.plan_handle) qp


The previous query will return any currently executing query on your system.  Using the CROSS APPLY is like using a left join, but on a Table Value Function, there is also an OUTER APPLY which is similar to the functionality as a right join.  In this case we are Using CROSS APPLY to return the Text of the SQL Statement being executed, as well as the Query Plan.


The Query Plan can have some over head associated with it, if you’re on a busy system I would recommend commenting out the Query Plan unless you’re truly looking for it.

SURE BUT CAN IT PLAY THE VIOLIN

So the DMV route is pretty well known, but how do you apply this in a non-troubleshooting capacity?  For this next example I’m using the AdventrueWorks2008R2 Database.

So let’s toss out a Case Scenario.  Our boss has come to us, there is an application that the company uses and as part of the expanded functionality we’ll be adding a lookup of Customer’s information.   We need to provide a list of Customer Names on demand, or the Name of a particular Customer, that are identified to us as People and not businesses.  (Not a complicated Scenario, but hey let’s start out practical).

If you Expand AdventureWorks2008R2 | Programmability | Functions| Table-valued Functions, you’ll see dbo.ufnGetContactInformation.  This Table Valued Function is exactly the type that we can use in the CROSS APPLY Statement.

Our Table Value Function accepts the @PersionID parameter, and we will be using the SALES.CUSTOMER table.   We take a quick look at the table to see what details we pull back.

SELECT
    *
FROM
    SALES.Customer

We see that names are not stored in this table, but we know we can retrieve them through our function.  Okay we don’t know that, but if you right click on the function and script it out you can read through it and see what it is doing.

So let’s use our CROSS APPLY statement.
SELECT
    ci.FirstName
    ,ci.LastName
    ,ci.JobTitle
    ,sc.AccountNumber
   
FROM
    SALES.Customer sc
    CROSS APPLY dbo.ufnGetContactInformation(sc.PersonID) ci

So now we can see that this can be used in a non-troubleshooting capacity.

 So let’s think about a couple other possibilities.  Let’s select an order being delivered and we want to know the last update in its location.  We have a customer looking at an item on a web page, and we want to display a coupon for the item.

There are a lot of possibilities for CROSS APPLY, I would suggest watching  the MCM Waits and Queues video by Paul Randal (blog|twitterthis link to the Demo will cover a great scripts by Glenn Berry (blog|twitter) using CTE’s & one by Joe Sack (blog|twitter) that makes a really good use of OUTER APPLY.

/*
How do you clear the server's wait
stats?
DBCC SQLPERF('sys.dm_os_wait_stats', CLEAR);

=================================================
BY: Glenn Berry & Paul Randal


CTE to get wait stats.

This CTE get's the wait stats as they are occuring on the
system and give's you the total seconds of wait, the
# of occurances, as well as the top percentage of where
your wait time is coming from. 

The Exclusions of certian wait types were recommendations
by Paul Randal in the MCM wait types video series
==================================================
*/

WITH Waits AS
(SELECT
    wait_type,
    wait_time_ms /1000.0 AS Waits,
    (wait_time_ms - signal_wait_time_ms)/1000.0 AS Resources,
    signal_wait_time_ms/1000.0 AS Signals,
    waiting_tasks_count AS WaitCount,
    100.0 * wait_time_ms /SUM(wait_time_ms) OVER()AS Percentage,
    ROW_NUMBER()OVER
    (ORDER BY wait_time_ms DESC)AS RowNum
FROM sys.dm_os_wait_stats
WHERE
    wait_type NOT IN ('CLR_SEMAPHORE','LAZYWRITER_SLEEP','RESOURCE_QUEUE','SLEEP_SYSTEMTASK','SQLTRACE_BUFFER_FLUSH','WAITFOR','LOGMGR_QUEUE','CHECKPOINT_QUEUE'
,'REQUEST_FOR_DEADLOCK_SEARCH','XE_TIMER_EVENT','BROKER_TO_FLUSH','BROKER_TASK_STOP','CLR_MANUAL_EVENT'
,'CLR_AUTO_EVENT','DISPATCHER_QUEUE_SEMAPHORE','FT_IFTS_SCHEDULER_IDLE_WAIT'
,'XE_DISPATCHER_WAIT','XE_DISPATCHER_JOIN','SQLTRACE_INCREMENTAL_FLUSH_SLEEP')
)


SELECT
    W1.wait_type,
    CAST(W1.Waits AS DECIMAL(12,2))AS Wait_S,
    CAST(w1.Resources AS DECIMAL(12,2))AS  Resources_S,
    CAST(W1.Signals AS DECIMAL(12,2))AS Signal_S,
    W1.WaitCount,
    CAST(W1.Percentage AS DECIMAL(12,2))AS Percentage,
    CAST(AVG(W1.Signals)/ W1.WaitCount AS DECIMAL(12,8))AS AvgWait_S,
    CAST(AVG(W1.Resources)/ W1.WaitCount AS DECIMAL(12,8))AS AvgRes_S
FROM
    Waits AS W1
    INNER JOIN Waits AS W2
ON
    W2.RowNum <=W1.RowNum
GROUP BY
    W1.RowNum,W1.wait_type,W1.Waits,W1.Percentage, w1.Resources, w1.WaitCount,w1.Signals
HAVING
    SUM(W2.Percentage) -W1.Percentage <99
/*
=================================================
BY: Joe Sack

This will give you the waits as they are happening
on a system, and give you the query text, as well
as the execution plans as they are occuring

I added the @@SPID to the query so we would not
see our own query plan come back while trouble
shooting
==================================================
*/


Select
    DB_NAME(est.dbid) AS DatabaseName,
    owt.session_id,
    owt.wait_duration_ms,
    owt.wait_type,
    owt.blocking_session_id,
    owt.resource_description,
    es.program_name,
    est.text,
    est.dbid,
    eqp.query_plan,
    es.cpu_time,
    es.memory_usage
from sys.dm_os_waiting_tasks owt
INNER JOIN sys.dm_exec_sessions es ON
    owt.session_id=es.session_id
INNER JOIN sys.dm_exec_requests er ON
    es.session_id=er.session_id
OUTER APPLY sys.dm_exec_sql_text(er.plan_handle) est
OUTER APPLY sys.dm_exec_query_plan(er.plan_handle) eqp
WHERE es.is_user_process=1
    AND es.session_id<> @@spid;
 
Here are the Scripts, but go watch to video to see how to use them!

Thanks,

Brad

Monday, April 11, 2011

Your Training is Approved! How Do You Get It Again?

With the upcoming SQL Rally there has been a lot of discussion amongst the community of how to help people ask for training. 

One of the first things to go in a tight economy is being sent to Training.  There is a lot of great information out there for free.  There are great blogs, videos, SSUGs (SQL Server User Groups) and not to mention SQL Saturdays.  As a DBA if you are looking to improve yourself there are a lot of great resources available to you.

“So Ball’s do you want me to go to Training or what?”

Glad you asked Dear Reader, yes I do.  The one thing that free training lacks that in-person training provides is social interaction.  Not only does this help you personally but professionally as well.

ONE OF THE MANY REASONS WHY

Two words, simple concept, Social interaction.  There are a lot of things that makes up a DBA’s job, and I’m not just talking Job Description.  What sets apart a really great DBA from others?  It’s not just what they know, don’t get me wrong you have to be knowledgeable in your field.  What sets a great DBA apart is something more fundamental than that, it is their social skills.

Social skills are just like any other that we have, if you do not utilize them then they rust.  If you practice them then they flourish.  When you are at a SQL conference, SQL Saturday, or SQL User Group this is your opportunity to stay sharp.  There is a lot of good information being passed around, ask questions, make points, discuss what you’ve done, and learn something.  This will help you when you get back to your job.

I would ask you to close your eyes and think of a meeting you’ve had at your company.  There is a complex technical issue, perhaps a production environment is down, and the Users/Sales are impacted.  How do people work together?  Do ego’s come out?  Is your opinion listened to and openly discussed?

 I cannot tell you how many MVP, Authors, and in-general SQL Legends that I’ve met that are nice, humble, and willing to listen in a complex technical setting.  If you do not work with a team of DBA’s, or if that team is not a cohesive team, then this is a refreshing experience.  Being in person with people from the SQL community is a treat and can help you use Technical  Social Skills that you can utilize in other areas of your job.

How To Ask

For great blogs on HOW to ask for training check out Kendal Van Dyke (blog|twitter) and Brent Ozar (blog|twitter)

If you need help on how to approach your boss, Kendal wants to help he is very available through his blog, or also on twitter.  Anything short of him having to pay your way, and he’ll be glad to help J.

Brent presents a lot of wonderful ways for you to approach your manager.  He also answers his comments, (as you can see by reading them), so if you have a situation that you don’t feel he covered ask him!  He is also readily available on Twitter.

***************UPDATE 4/11/2011**********************************************

Later in the day while at work I discovered that the Awesome people putting together SQL Rally had a great ROI section that was posted in March.  Not only are there wonderful arguments listed as to why you should go, but there is also a great form letter that can help you ask to big boss to be able to attend.  I had to include the links to this.

ROI For SQL RALLY and HOW to ASK YOUR BOSS

*************AND NOW BACK TO YOUR PREVIOUSLY SCHEDULED BLOG POST******

YAY YOUR APPROVED!

I want to focus on the idea that you have been APPROVED to go.  Your SUPER EXCITED, and you should be!  But through the haze of the excitement you need to consider a few tings.  You don’t want this to be a one shot deal.  You want to go to training again.  So how do you make that happen?  You need a plan.  So ask yourself the following:

1.       What am I going to Learn?
2.       How Will I apply it when I get back?
3.       How do I show my Boss the Training was worth it?

WHAT AM I GOING TO LEARN: SQL WINNING

So your approved to go, now is the time to look at the track’s being offered and determine what your 1st, 2nd, and 3rd choices are for each time slot.  But as you decide I’d like you to think of any issues or new technologies that are being used by your company.  Try to set yourself up to be a returning superstar.

You should think about the projects your working on, or the upcoming one’s you know you’ll be roped into working on. 

If you are working on a project to get your arms around your SQL Environment then look for Sessions on Policy Based Management, Auditing, and Powershell. 

If you are looking at adding High Availability to your environment look for Sessions on Disaster Recovery, Mirroring, Replication, and Clustering.  If Performance is where you need to concentrate look for Sessions on Indexing, Wait Stats, and Compression. 

The point is knowing where you are going and what you NEED to learn to get there will help you achieve some WINNING in the long run.

YOU WENT, YOU SAW, YOU CONQURED, YOU PROBABLY GOT A T-SHIRT

So now it’s Monday and your back at the office.  Your inbox is not Zero, you’ve got meetings, and a to-do list a mile long.  What did we get out of our trip?

While things are fresh it is easy to be excited and ready to go, back at the office reality sets in.  Now is when I like to make a list.  You should do a top 5 things that you learned from training that you want to apply to your job.  If you have co-workers that went to training with you, you can talk to see what their top 5 things are, and align them to work together.

We attended some training a couple months back, and when we returned I had a list of what I thought the top 5 things we could apply were.  The number 1 thing that I wanted to do was pretty low on the list.  After talking with all the other DBA’s it turned out that was the number 1 thing on their list, which they thought could benefit the company right away.

So now that you’ve got your list, and your co-workers are on board, set up a road map of how you will present this to your boss.

Let’s take Policy Based Management for example.
  1. Find a Dev, Test, or local SQL Server Instance on a Laptop that can Server as your Central Management Server.
  2.  Register the instances you would like to run Policy Based Management Against. 
  3. Work with your co-workers, determine policy’s that are most beneficial to your environment. 
  4. Set them up and Run them.
  5. Demo it for your Boss
There are so many features in SQL Server to take advantage of, that it is rare to find a place that has it all figured out.  There is probably something that could benefit your work place that you are not currently using:  Snapshots, Mirroring, Backup Compression, Filtered Indexes, Sparse Columns, Policy Based Management, Data Compression, Central Management Server the list is long. 

If you can find something to apply, and actually get it in place, then future training should be easy to obtain.

What if you didn't find anything new?  What if you were the only DBA to go?  When you come back try to share the wealth.  You just spent some time watching a lot of people present on topics, now is your chance to try with your co-workers.  Work up some of the topics where you learned or gained a clearer understanding of how something works.

  1. Work up a Summary of the Topics and some Demos (grab the decks and scripts if they are available for download)
  2.  Set up a meeting with your co-workers
  3. Present the topics
  4. Get Feedback, go back to the top and start working on your top 5 list with your co-workers on board


SHOW THE TRAINING WAS WORTH IT

Here’s the big payoff.  The next time you try to go to a conference, when your boss hems or haws you say “Hey boss remember problem xyz, and how I fixed that after training.”  Or even better “Here’s how we improved things after training.”

Businesses are all about Return On Investment, ROI, if you can show them that sending you to training is an investment they will get a return on then you’re already on your way to your next round of training.

I hope to see you at SQL Rally this year and next!

Thanks,

Brad