T-SQL Tuesday #37: JOIN Formatting… It’s all about S-T-Y-L-E…

T-SQL Tuesday #37 is upon us, with this month’s topic being about Joins, as hosted by Sebastian Meine.  While there will be many others writing about the how’s and why’s about Joins, I’d like to contribute something about style of formatting the syntax of Joins.  In my experience working from project to project, it can be truly daunting to inherit T-SQL code where the Join syntax is difficult to read due to bad or no formatting.  Consider this simple yet unformatted T-SQL query, displayed in the monospaced font, Courier:

While it may take no more than a minute to read and see what is happening here, consider the following three examples on better ways to format the query (note that the default TAB size if four characters):

Each of the examples above has their own pros and cons as to why they’re preferred over the other.  I have seen many blogs where the version 1 example is used by many.  I myself prefer version 2, but in my last project I worked on, my colleague who was the lead on the project team preferred version 3.  Whichever or however Join formatting is used, my message would be: format your Join syntax with more than just the version 0 example above, and be consistent with it in your T-SQL code.  With this in mind, I followed the lead of my colleague and used the version 3 formatting on the project, to keep consistent the look and feel of the T-SQL we deployed for the project.

Just remember, pick a formatting style for your Joins that make the Join syntax readable, and stay consistent with that style!

My two and a half cents!…

Recounting PASS Summit 2012, Part Three…

So now we’re at day three of PASS Summit 2012, or at least, my third day.  You can follow these links to see my day one and day two recaps.  The third day, Friday, followed a wonderful Thursday evening at the EMP, and it did not have a key note in the morning.  Still, I made it to the conference for the second session of the day…

Lightning Talks : Friday November 09 : 09:45 AM – 11:00 AM

  • Christian Wade – Is It an Alligator? Is It a Crocodile? No, It’s a Gecko!
  • Edwin Sarmiento (Blog / @EdwinMSarmiento) - Presentation WOW
  • Julie Koesmarno (Blog / @MsSQLGirl)- TRY CATCH in a Nutshell
  • Laerte Junior (Blog / @LaerteSQLDBA) - T-SQL Health Check to Excel in Email in 10 Minutes with PowerShell
  • Neil Hambly (Blog / @Neil_Hambly) – Effective Error Log Parsing

Now this was a treat.  Several presenters doing 10 minute sessions, focusing on the highlights or the important aspects of their topics.  I will admit, I wanted to catch Julie for the most part, as I tried to attend her SQLLunch.com presentation, “Ready Steady Catch”, a couple weeks back.  I was able to attend initially, but given I was in the office at the time, work duty called, so I could not sit for the entire presentation.  So I made sure to get to her lightning talk.  And really, I’m just a fan.  However, the other speakers were great in their own right.  Christian offered his reptilian take on BI.  Edwin, fellow Filipino extraordinaire, had a very engaging and energetic session on how presenters, no matter the topic, should wow their audiences; you can really tell Edwin rehearsed his presentation many, many times, and it truly showed.  Laerte is a diehard Star Wars fan, adding fandom-inspired humor to his PowerShell demo.  And Neil gave us an abbreviated yet in depth look as parsing the error log.  There was one no-show to the lightning talk session, so Edwin dug up another 10 minute presentation and proceeded to provide another inspired and enlightening talk.

The Key2 Consulting crew took time at lunch to hit the Pike Place Market and had a great lunch at Lowell’s Restaurant.  After a little sightseeing of the Seattle waterfront, it was back for one final session…

Extending SSIS 2012 Reports with Analytics - Friday November 09 : 02:45 PM – 04:00 PM
Patrick LeBlanc (Blog / @PatrickDBA )

Patrick ended up co-presenting with Julie Koesmarno for his session on SSIS 2012.  Really, though, he made Julie do all the work.  The bum!  All kidding aside, Patrick is a great fellow who I follow on Twitter and is the man behind SQLLunch.comNo fluff, just stuff. Now, he’s a Microsoft guy, having been a part of Thursday’s BI Power Hour.  But watching Patrick in person is a must see for those who have only listened to him from SQLLunch.com or other online sessions.  If you’re late to his session, he’ll pick on you, for sure.  But aside from levity, Patrick and Julie both offer thier seasoned views on taking data from the Cloud via SSIS 2012 and consolidating the analytic data now available via SSIS 2012.

After the session, the Key2 crew headed off from Summit 2012 to take in the latest James Bond flick, capping off a great PASS Summit 2012 experience.  The rest of the crew has either a redeye or early Saturday AM flight back to Atlanta, while my flight was not until 11 AM on Saturday morning.  Next year, PASS Summit 2013 will be closer to home in Charlotte, NC.  Hope to be there again to learn, to network, and have some fun.  Thanks for reading!

Just my two and a half cents…

Recounting PASS Summit 2012, Part Two…

The other day, I recapped my first day at SQL PASS Summit 2012. By the second day, Thursday November 08, the time difference from the East Coast to the West Coast was getting to me, so I did not make it to the second keynote; I’ll have to follow up on the recording another time. However, I made it to four sessions during the day, while making sure to be able make it to the Microsoft sponsored event at Seattle’s EMP later that evening.

At the EMP, later in the evening...

Query Tuning Mastery: The Art and Science of Manhandling Parallelism : Thursday November 08, 2012 : 10:15 AM – 11:30 AM
Adam Machanic (Blog / @AdamMachanic)
This session interested me the most even to this day, as I review the recording that was added to the end of the Day 2 Keynote that captured this session. I follow Adam via Twitter so it was great to see the man in person during his presentation, though he was in the big auditorium room where the overflow for the Keynote was held. I would have loved to apply his tuning principles right away, but I’m off to another client that has more ETL needs that SQL tuning, but this would have helped tremendously with a prior client. Who knows? I may find myself there again… Anyway, big tip Adam shared while tuning SQL within SSMS was to do the following:

  • Actual Execution Plan enabled
  • Client statistics enabled
  • Discard results after execution

While it’s best to review the recording as a whole, in short from Adam’s sample files, the APPLY pattern he uses is as such:
–The Parallel APPLY Pattern
SELECT
x.[columns]
FROM [driver set] –< This is where you define your chunks
[CROSS/OUTER] APPLY
(
[correlated payload] –< This is where all of the work is done
) AS x

What to Look for in Execution Plans : Thursday November 08, 2012 : 01:30 PM – 02:45 PM
Grant Fritchey (Blog / @GFritchey)
Grant is another gentleman I follow on Twitter, so again, it was a joy to see the individual in person for his presentation. And after Adam’s session prior to lunch, Grant’s session would reinforce what to look for while examining execution plans. However, I will admit, the past two lunches provided by PASS (Wednesday and Thursday) were very good, and thus it was a challenge to stay totally alert throughout the session. Thankfully, there’s Seattle’s Best coffee waiting outside.

Database Design Throwdown : Thursday November 08, 2012 : 01:30 PM – 02:45 PM
Thomas LaRock (Blog / @SQLRockstar) , Karen Lopez (Blog / @DataChick)
Ahh, the Rockstar versus the DataChick. This was a great session to attend, seeing another pair of Twitter peeps that I follow. It turned out to be SRO (standing room only), so I was glad to have gotten a seat in the room. Tom and Karen via a throwdown session offered two opposing sides of database design issues. Normalization versus not; Nullable versus non-Nullable fields; DBAs versus Developers versus PMs. It was great! The energy was high and helped to keep the audience engaged, educated, and entertained. Plus the coffee beforehand was kicking in, too!

BI Power Hour : Thursday November 08, 2012 : 05:00 PM – 06:15 PM
Matt Masson, Chuck Heinzelman, Matthew Roche, Patrick LeBlanc, Peter Myers, Sean Boon
This was another highlight from Summit 2012. There was lots to learn, especially about hugs and tapping everything. Suffice to say, you had to be there.

After the sessions, the Key2 crew headed out to dinner at Dragonfish Asian Café a block or so from the conference. What can I say? There was Tempura Bacon to be had, and Sake to boot!

And finally, the day ended at EMP http://empmuseum.org/. While there was SQL Karaoke to be had, one of the highlights was the Icons of Science Fiction exhibit, where this bad boy below can be found.

But the other highlight was the debut of the awesome rock band, the Krooked Keys 2 [Squared]! Follow the link below to watch our one-night only performance. Only true rock fans can appreciate the awesomeness!

Recounting PASS Summit 2012, Part One…

 

So last week, I along with almost 4,000 attendees participated in PASS Summit 2012 in Seattle, Washington, between Wednesday November 14 through Friday November 16.  This didn’t include the many who attended PreCons on Monday and Tuesday, totaling over 5.5K of registrations.  The underlying theme I found while attending PASS Summit 2012 was SQL Family.  Now, I know I’m not that well connected to the SQL Family as many are, but I do like to watch from afar, keeping tabs on the notable SQL peeps via the internets and all.  So for me, finally being able to meet a few in person or via participating in their sessions was a real joy during PASS. 

My blog entry today is part one of several entries made to recap the sessions I attended, what tidbits I was able to learn, and to highlight the people and events around PASS Summit 2012.  This first entry recaps day one of PASS, Wednesday November 07.

The First Keynote : Wednesday November 07, 2012 : 08:15 AM – 10:00 AM

An introduction was made by Bill Graziano (Blog: SQLTeam.com | @BillGraziano), where among speaking about SQL Family, Bill announced the upcoming PASS Business Analytics Conference (@BA_Conf), to be held in Chicago, Illinois in April 2013.  But the keynote itself would be handled by Microsoft’s very own, Ted Kummert, where he along with other Microsoft employees talked on how to “Accelerate Insight on any Data”.  The highlights of note were, as summarized by Steve Hughes ( Blog: Data on Wheels)

  • Hekaton: the project code name for a new in-memory OLTP engine
  • The Columnstore Index will be updateable
  • Next version of PDW will be out in H1 2013
  • Polybase: allows you to query across multiple types of data sources such as SQL Server and Hadoop with T-SQL
  • DAX Queries will be able to query SSAS Cubes
  • Microsoft HDInsight Server CTP: Hadoop for Windows Server
  • Windows Azure HDInsight Service Preview: Hadoop for Azure
  • Power View and PowerPivot fully implemented in Excel 2013

 

10 Extraordinary Things to Achieve with Integration Services 2012 : Wednesday November 07, 2012 : 10:15 AM – 11:30 AM

Peter Myers (PASS Bio), Matthew Roche (PASS Bio)

For the first session after the exciting keynote, the balance of calm and cool Peter to the hyper and electric Matthew made for an insightful recap of why we use SSIS in implementing ETL solutions.  Newcomers to SSIS can take away the many things that SSIS can do for them, while experienced users (I’d like to think I’m experienced, more so than where I was a year ago) can recap everything else SSIS can do.  Here’s the recap of the outline and the delivery points, from their posted slide deck:

Session Outline

  1. Exporting/Importing Binary Data
  2. De-Duplicating Data
  3. Implementing Custom Logic with Scripts
  4. Leveraging CDC
  5. Cleansing Data with Data Quality Services
  6. Integrating Data Mining Predictions
  7. Working with Environments
  8. Working with the SSIS Catalog API
  9. Implementing a Data Tap
  10. Monitoring and Analyzing SSIS Catalog Data 

SQL Server Integration Services delivers

  • A rich set of features and capabilities
  • A robust, flexible, fast, scalable and extensible architecture
  • While it was primarily designed to implement ETL processes, it is also useful in many other scenarios:
  • Assessing data quality
  • Cleansing and standardizing data
  • Merging data from heterogeneous data stores
  • Implementing ad hoc data transfers
  • Implementing ad hoc data manipulation
  • Automating administrative tasks

 

Adapting Your ETL Solutions to Use SSIS 2012 : Wednesday November 07, 2012 : 01:30 PM – 02:45 PM

Devin Knight (Blog | @Knight_Devin)

After lunch, I made a point to go see the session from an old friend from Jacksonville, Devin Knight.  And the topic was in line with an upcoming project I hope to be a part of and start in 2013 as the project will look to move existing ETL packages towards SSIS 2012.  A demo heavy session, I took away the following bullet points:

  • Use the SSIS 2012 Wizard to convert older packages to SSIS 2012 with SSDT, which is SQL Server Data Tools; it is no longer called BIDS
  • Packages can still use Legacy Mode to access file-based packages
  • However, use of Legacy Mode will not leverage SSISDB
  • SSISDB is where the advantages of SSIS 2012 happen

  

The afternoon ended some visits to the sponsor booths and some feet resting, as the jet lag from flying from Atlanta to Seattle the day before caught up with me.  I was able to later join my Key2 Consulting colleagues and participate in Bill Speidel’s Underground Tour of Seattle http://www.undergroundtour.com/.  It was a very educational and enlightening tour and history lesson of Seattle.  If you have about a couple of hours to spare to learn about crappers and seamstresses, and can handle some light walking up and down stairs, it’s a must see in Seattle. 

 

After dinner and a few cocktails with Key2 crew, I was able to make a very late albeit brief visit to Pragmatic Works’ SQL Karaoke event at the Hard Rock Café.  Yeah, we arrived late, but arrived in time to see several SQL ladies entertain the crowd to their rousing rendition of Sir Mix-A-Lot’s “Baby Got Back”.  Yeah, you had to be there to see/hear it.

And after a brisk walk in the Seattle Fall night back to the Crowne Plaza hotel, it was off to bed, and one day down for PASS Summit 2012.  Next up, Thursday…

   

As always, just my two and a half cents…

SharePoint 2013 Configuration Wizard Error

While deploying the SharePoint 2013 preview on a VM, I ran into a small problem.  The install itself ran great, but I kept getting an error while running the SharePoint 2013 Products Configuration Wizard.  Essentially the error was indicating that a component didn’t support running under the NetworkService account in a Workgroup environment.

A bit of searching and I found that a couple of other people have already run into this and solved it.  Here is the best explanation I found.  The error is for the AppFabric caching component.  Once I followed the steps Tom lays out in his workaround, I was able to re-run the Config Wizard and everything is back on track.

Updated SSIS Attunity Connectors for Teradata and Oracle Released

I have used both the Teradata and Oracle connectors in the past.  While there are some “gotcha’s” (for example you must have SQL Enterprise), overall they provide the fastest possible way to extract data from either of those two sources.  v2.0 brings support for SQL 2012 and the latest releases of Teradata and Oracle, as well as bug fixes and enhancements.  Interestingly, it appears that “v2.0” is only for SQL 2012 and “v1.2” is included and intended for SQL 2008 / 2008 R2.

I originally saw this as a post by Matt Masson to the SSIS Team Blog.

You can download the updated connectors here.  Here is the overview from the download page:

Overview

Microsoft Connector Version 2.0 for Oracle by Attunity – The Oracle source and destination components are written to achieve optimal performance when loading data into Oracle or unloading data from Oracle in the context of Microsoft SSIS.
Microsoft Connector Version 2.0 for Teradata by Attunity - The components are written to achieve optimal performance when loading data into Teradata or unloading data from Teradata in the context of Microsoft SSIS.
Microsoft SSIS Connectors by Attunity Version 2.0 is a minor release. It supports SQL Server 2012 Integration Services and includes bug fixes and support for updated Oracle and Teradata product releases.
The following enhancements were made:

  • Oracle Enhancement – LOB Support
  • Support was added for the following Oracle LOB types: CLOB, NCLOB and BLOB. These LOB types are supported by the Oracle Source component and the Oracle Destination component in array load mode.
  • Oracle and Teradata Bug Fixes – Some hot key issues were fixed in the Oracle and Teradata connectors UI.
  • Oracle and Teradata Bug Fixes – Localization issues were fixed in the Oracle and Teradata connectors.
  • Teradata Enhancement – Support for TPT API 14.0 and TPT API 13.10.
  • Support was added for Teradata 13.10 and Teradata 14.0 by supporting TPT API version 13.0 and TPT API version 14.0 (14.00.00.02 or higher). Previous versions of the TPT API are still supported.
  • Teradata Enhancement – Starting from Teradata 13.0 Teradata database supports DDL with no primary index which was introduced specifically for loading data faster into Teradata; these tables were not listed in the table dropdown list.
  • Teradata Bug Fix – Teradata DDL supports column names being reserved words. Teradata Connector could not work with tables having such columns.
  • Teradata Bug Fix – Teradata destination component failed to read problematic rows from the error table with the following error: “Errors while trying to read error tables. Invalid TPT operator”.

Complete SQL 2012 Demo Build Script

There is no need to download the 28GB BI Image X (which at the time of this writing hasn’t been updated to SQL 2012 RTM).  There are instructions on how to build an all-up SQL 2012 and SharePoint 2010 demo VM with instructions for configuring all of the latest SQL 2012 tools including DQS, MDM, PowerPivot for SharePoint and more.  The full instructions are here.  This is a great way to familiarize yourself with a full deployment of the latest BI software from Microsoft.

Here’s the summary from the link above:

This how-to article will guide you through the process of building a Hyper-V virtual machine with Microsoft SQL Server 2012, the latest Visual Studio 2010 development tools, SQL Server Data Tools (SSDT), and an assortment of other software products to create a test environment ready for testing and product demos.

Fix for Excessive VMWare Disk Activity On Host After Suspend or Shutdown

I use VMware to run 64-bit guest OS’s for development and testing on my laptop.  (Windows 7 only allows 32-bit guests, Windows 8 incorporates Hyper-V so this limitation will go away soon).  One of the nice benefits of running a VM is that I can suspend and bring it back online in a matter of seconds each time I want to use the VM.  Unfortunately, this comes with a negative side effect – the drive on the host that I am storing the VMs on thrashes for up to 15 minutes after VMWare was closed.  At the end of the day, if I had just suspended my VM and tried to shut down the Windows 7 host OS, it would take 15 minutes to shut down the laptop.

Fortunately I found the fix on a SharePoint blog.  Essentially you have add a setting to the VMWare config file.  For VMWare 7, the file is located here: C:ProgramDataVMwareVMware Workstationconfig.ini.  The setting that you need to add is mainMem.useNamedFile = “false”.  One thing to be careful of is if you copy/paste from the web, the quotes on the “false” will be curly directional style rather than the straight kind that are required for the config file.

One other setting that I changed was in the main preferences for VMWare under the Memory tab, I set the “How should the system allocate memory for virtual machines?’ to “Fit all virtual machine memory into reserved host RAM”.  I am able to do this since I have 16GB of RAM on my laptop, not sure if this is quite as feasible with less RAM.

Add SSD to Dell Precision

I just received a new Dell Precision M4600 from work. I wanted to install Windows on a SSD so that it would fly. I know that if you are configuring the m4600 on the Dell website, you are given the option to add a 2nd 128GB (SATA3) Mobility Solid State Drive for just $480.00.

Since my laptop was ordered for me, I did not have the option to add this on, and $500 is a bit much when you can purchase a 128GB SSD for $100-$200. I called Dell to find out what my options were. After several calls and live chats, I was told that there were 0 options to add on a new SSD disk.

I did a little digging on my on and found 2 options.

  1. Replace the DVD drive with a HD Caddy and install a 2.5″ SSD. The main problem with this approach is that you will loose your internal DVD drive.
  2. Install a mSATA SSD. This can be installed in the WWAN slot. I don’t have a WWAN card so that makes this an easy decision.

I purchased a Kingston 64 GB mSATA SSD for $89 on Amazon. Here are the very simple steps to install the mSATA card

  1. Remove Battery
  2. Remove the Base Cover
  3. Install mSATA card in the WWAN slot. You will also need 1 tiny screw. I don’t know the size or name. I just hapended to have one.

    Dell has some really good step by step instructions to installing components.
    Dell’s Precision M4600 Owner’s Manual - http://support.dell.com/support/edocs/systems/wsM4600/en/SM/index.html

After putting the cover and battery back in I turned on my PC and Windows instantly recognized the drive. I went into my Disk management and formatted the drive. Being a SSD it took about 15 seconds. Then I installed window to the new drive.

When installing Windows you want to make sure that all you user files and program files get installed to your main hard drive and not your SSD. Make sure that you run RegEdit and edit the following before installing any other programs or creating any users

Microsoft BI Image X: SQL 2012 RC0 Available for Download

Periodically Microsoft refreshes their BI Demo virtual image that contains a fully configured instance of their latest BI tools with demo data.  Last week they made the latest version available for download.  They are calling it BI Image X and it contains SQL 2012 RC0 and it is available here.  This one contains the new PowerView tool, as well as SharePoint and PowerPivot.  You will need a minimum of 8GB of RAM allocated to the VM.

Here’s the official description:

The Base ImageX Server is a virtual machine that can be hosted in Hyper-V that allows a user to test out the latest Business Intelligence features of SQL Server 2012 – RC0. The virtual machine has been configured to support the use of PowerView reports, PowerPivot Excel documents and various content packs allowing the user to explore the capabilities of SQL Server 2012. Working with the demos that can be installed on the ImageX server the user will have a clear picture of how the SQL Server 2012, Office and SharePoint tools support and enhance the self-service business intelligence environment.

**If you need to convert to VMWare to run on your dev machine (How come Windows 7 still  doesn’t support 64-bit VMs?), you can use VMWare vCenter Convert to convert the virtual hard disk to VMware.