Archive for T-SQL Tuesday

T-SQL Tuesday #38 – There Is No Spoon

T-sql TuesdayJason Brimhall (B|T) is hosting this month’s T-SQL Tuesday blog party. (Thank you Jason!) The party was originally started by Adam Machanic (B|T) just over three years ago. The topic this month is “Standing Firm”. Jason had a great list of New Year’s words for this topic: Resolve, Resolution, and Resolute. I immediately thought of the word “Resolute” and how I am determined to have my blog be successful on my terms.

I have been given many talents, but writing “proper English” is not one of them. A simple blog post can take me hours not only to write but to reword, correct grammar and spelling, and make sure I’m consistent with my personal pronoun usage. But I am determined and Resolute about having a blog to share my knowledge and to proudly call my own. Thinking of my challenge I thought of Neo from The Matrix. He meets a prodigy at the Oracle’s home and she is bending spoons with her mind. Neo tries to bend the spoon by staring at it, but nothing happens. She tells him the secret is, “There is no spoon”. After he realizes she was correct, he is able to bend the spoon with his mind. Would he have been able to bend the spoon if he had never met her? Most likely not. He had to learn to see his reality differently so that he could achieve what he thought was impossible. Being able to write when it is not “my talent” can be approached the same way.

The first thing the “Resolute Writer” needs, is to determine where the weaknesses are and find tools to help overcome those weaknesses.

Tools For Planning

The first thing I do when I know what I’m going to write about, is I create a mind map. A mind map is a diagram that illustrates the ideas I have on a subject. All I need is a piece of paper and a pen, but since I’m a geeky girl…I use my iPad. I have this great program called Grafio. It allows me to create mind maps and save them as images. Here is the mind map for this blog post.

Mind Map T-SQL Tuesday 38

Since I love color as much as I love SQL, I color coded my mind map. The pink circle is my main topic, and the purple and aqua circles are used as my grouping mechanisms for the gray circles which contain the ideas.

Outlines are a great tool for working out the flow of a blog post. There are even products out there that turn mind maps into outlines, but I have not used them. Microsoft Word and simply numbering the circles on a mind map are other tools for creating outlines.

Ginger is a tool I use to correct not only my spelling, but also my grammar and word usage. However, it isn’t perfect. Technical languages like SQL can be challenging for Ginger, but overall I find Ginger to be a wonderful tool for me.

Help Beyond The Borders

When Neo was stuck in the train station in the third Matrix movie, he tried to will himself out just like he willed the spoon to bend. He found it difficult. I’m sure if he had been given more time, he could have willed himself out, but Trinity was willing to help get him out. Writing is no different. I can ask just about anyone in my life to proof read what I write, and sometimes I do. I had my husband Dan proof read my last blog post on Mentoring, and I had my daughter Victoria proof read this blog post.

Another way to improve my writing skills, is to write for someone else, because they will definitely have an opinion on my writing ability if it’s not up to par. For me, my first post for MS SQL Tips came out yesterday (Working With Multi-Select Parameters for SSRS Reports). I also try to visit different SQL forums to answer questions. This allows me to test my own knowledge as well as allow me to explain to someone else, with written words, how to fix their problems.

Finally I have a goal to participate in as many T-SQL Tuesday’s as possible. This gives me two things:

  1. A topic that I didn’t have to think up.
  2. A time frame to write (1 week) with a deadline ( 2nd Tuesday) that is manageable.

Follow the White Rabbit

The best thing I can do for my writing, is to be true to myself. If I’m true to myself, and my SQL code is sound, then a couple of misspelled or badly placed words won’t matter to the readers. They will remember my posts for the content.

In the end, writing is as scary as deciding between the blue pill and the red pill, but I choose the red pill and I plan to see how far down the rabbit hole I can go.

T-SQL Tuesday #37 – RIGHT JOIN, LEFT JOIN, raw, raw, raw

T-sql TuesdayThis months T-SQL Tuesday blog party is being hosted by Sebastian Meine, PhD (blog). The topic is on JOINS. I’ve chosen to blog about how to rewrite a RIGHT JOIN I found this week in a stored procedure.The query was simple, but it was difficult to read without creating a data model and understanding the relationships of the tables. I decided to rewrite it to make it easier to maintain in the future. I have created a sample data model to demonstrate the problem and the solution. The data model has a table for Sales Reps,a table for Regions which the Sales Reps belong to (optionally), a list of Clients, and a linking table which links the Clients and the Sales Reps.

The query that was created, returns all the Clients and any associated Sales Reps with their regions, even if the Sales Rep is not assigned to a region. The original programmer used a RIGHT JOIN  to join the SalesRep table to the ClientSalesRep table. They also put the predicate for the SalesRegion table after the SalesRep table. While the Optimizer has no problem reading this query, I had to stand on my head to figure it out.

   dbo.Client AS c
   LEFT JOIN dbo.ClientSalesRep AS cus ON c.ClientID = cus.ClientID
   LEFT JOIN dbo.SalesRegion AS sr
   RIGHT JOIN dbo.SalesRep AS srep ON srep.SalesRegionID = sr.SalesRegionID
										ON cus.SalesRepID = srep.SalesRepID

I rewrote the query using only LEFT JOINS and each table had its own predicate. I found the LEFT JOINS made it easier to read and didn’t give me a headache.

   dbo.Client AS c
   LEFT JOIN dbo.ClientSalesRep AS cus ON c.ClientID = cus.ClientID
   LEFT JOIN dbo.SalesRep AS srep ON cus.SalesRepID = srep.SalesRepID
   LEFT JOIN dbo.SalesRegion AS sr ON srep.SalesRegionID = sr.SalesRegionID


I populated the tables with a million rows to see if the Optimizer would treat these queries differently. It didn’t. They had the same query plan, the same number of reads, and the same statistics, but it was easier to read.

Thanks go to Sebastian for hosting T-SQL Tuesday this month. Check out Sebastian’s blog, because he is blogging about JOINS all month.

T-SQL Tuesday #36 – What Community Means to a Newbie

The 4th quarter of 2012 has marked many firsts for me. I attended my first SQL Saturday and my first PASS Summit. I joined my first SQL User’s Group. I started a blog, and now I’m participating in T-SQL Tuesday. This month’s topic is about what community means to me. Since I have only recently found this amazing community, I’m blogging about the community from a Newbie’s perspective.

In the beginning…..

I knew no one in the SQL community outside of my IT department. The database side of my IT department has less than 5 people. I desperately searched for a local SQL Users group, but I couldn’t find an active one, so I widened my search criteria. I found I was half way between the LA SQL PASS chapter and San Diego SQL PASS Chapter, both of which are 50 miles away and a 1.5 to 2 hour drive on a Thursday night. What to do, what to do.

I lucked out. On Sept 15th, 2012 the San Diego SQL PASS Chapter (SDSQL) was hosting a SQL Saturday (#157).

It changed my life.

I drove down to San Diego (by myself) not expecting much. I took Jason Strate’s (B|T) session on Discovering the Plan Cache. His session was so good, that I changed my schedule and attended his other 2 sessions. By the end of the day, I was happy with the day, but I had hardly said two words to anyone. I had really wanted to network, but my shy side had stopped me (yes I do actually have a shy side. It’s very small, but it’s there). Phil Robinson, the president of the chapter, invited everyone to a local sports bar for dinner and I went.

This is where the magic happened.

Before I even went into the building I was greeted by someone from Quest. She happens to work in the building next to me. She introduced me to others and I finally began to network. As the night moved on, I met Phil Helmer (B|T) and everything really changed. He introduced me to other frequent members of the local chapter, as well as some of the speakers. We talked about the PASS Summit 2012, which I wasn’t going to be able to attend until 2013. After talking to Phil for a couple of hours, I decided I wanted to go this year, so I convinced my manager to let me go.

Phil was also the one who convinced me to set up a Twitter account, which I’m now an active member of. Twitter has provided me a way to stay in touch with the SQL community. It has also provided a way to help others with SQL questions.

That night I also struck up a conversation with Benjamin Nevarez (B|T). I told him how I use to be a Microsoft Certified Trainer and I wanted to start speaking on SQL topics in a year or two. He thought that goal was too far away and that I should speak at the next Huntington Beach SQL Saturday coming up in early 2013. He was very encouraging and has convinced me to submit a proposal.

But it gets better.

Fast forward to a couple of weeks prior to SQL PASS Summit 2012. I received an email from Joe Fleming (T). He was to be my mentor for Summit 2012. He was so helpful, answering all my questions and making sure I met people at the Summit. He’s not the only one either. Before the Summit even started, I had met new people on Twitter who would be attending the conference. Once I arrived at the Summit, I didn’t sit still for a week. I met so many fabulous people, and they accepted me, just the way I am. I never felt like the ugly stepsister. I never felt like the eccentric artist. I was never shut out because I’m Christian. I was accepted.

I was part of the SQL community.

Update: After reading the other T-SQL Tuesday #36 blog posts. I realized that I hadn’t thanked the host, Chris Yates (B|T) for hosting this month’s SQL blog party. Thank you Chris.

%d bloggers like this: