- T-SQL Tuesday #015 – Automation (summary)
- T-SQL Tuesday #016 – Aggregation (summary)
- T-SQL Tuesday #017 – APPLY Knowledge (roundup)
- T-SQL Tuesday #018 – CTEs (wrapup)
- T-SQL Tuesday #019 – Disasters and Recovery (wrapup)
- T-SQL Tuesday #020 – T-SQL Best Practices (wrap-up)
- T-SQL Tuesday #021 – A Day Late and Totally Full of It
- T-SQL Tuesday #022 – Data Presentation (round-up)
- T-SQL Tuesday #023 – Joins (summary)
- T-SQL Tuesday #024- Prox N Funx (Summary)
- T-SQL Tuesday #025 – Invitation to share your tricks (summary)
It doesn’t seem that long ago that having cool little tidbits of information about SQL Server made a huge difference in how effective you could be. Well, that’s still true, but let me give you an example.
SELECT name FROM sysobjects WHERE sysstat & 4 > 0
In the early days of SQL Server, this was the way to pull a list of the names of all the stored procedures in your database. The 4 bit in the sysstat column represented stored procedures. (1 represented user tables and 2 represented view, as I recall, so changing the WHERE clause to read WHERE sysstat & 7 > 0 returned all tables, views and stored procedures.)
As SQL Server has evolved, Microsoft has made it easier to query the metadata to determine what objects existed, adding columns that helped (like ‘Type’ in this case), catalog views, Dynamic Management Objects, etc.
So, the challenge for this month’s T-SQL Tuesday is: What T-SQL tricks do you use today to make your job easier? (Notice I didn’t say PowerShell – I have a bunch of those now, but this is T-SQL Tuesday, not PowerShell Tuesday.)
You are hereby invited to this month’s T-SQL Tuesday #024, which will take place on November 8, 2011.
So, all you T-SQL Bloggers out there, please join the blog party and write up something revolving around this month’s topic: Prox ‘n’ Funx (which is just a coo-ul way of referring to Procedures and Functions).
This topic covers a lot of ground, so there’s a myriad of possibilities in what you can write about. You could discuss a really cool stored procedure or function that you wrote. You could write about a Dynamic Management Function that you can’t live without… or perhaps write about some of the new functions that are coming in SQL2012. How about limitations or “gotchas” or performance issues in working with procedures and functions? And on and on and on…
Topic d’jour? JOINS (I’m in a fundamentals mood lately). Note that I also like creative and esoteric posts, so if you can find a way to apply SQL as a metaphorical language for community activity, I’ll read it and enjoy it. If you just want to tell me in a simple fashion the difference between a HASH and MERGE join, I’m cool with that, too.
On to this month’s Topic
What I have described above may be some behind-the-scenes details, but nevertheless, I packaged it in such a way that would provide entertainment (maybe ridicule?) to the reader at large. This was my presentation to the reader.
Therefore, the topic of this month’s T-SQL Tuesday is, “data-presentation” Or put better, formatting data for presentation to the end-user.
We may be the developers, and techno-geeks behind the code, whether simple, advanced, spaghetti, or otherwise. But, the data the user sees is most critical. The query output, the report, or data presentation, must be absolutely formatted in such a way that is easily understandable and readable by the end-user. The end-user can be the boss, supervisor, department head, the analyst, employees, or customers. And they must be the ones we cater our queries to!
It helps a lot, if we can simplify our code too. For example, when doing comparative analysis of the dataset results returned by a query, it makes it completely understandable if the output includes a percentage column. While for the end-user, it may be hard to digest milliseconds, megabytes, totals, and other assorted aggregated data, everyone can easily comprehend when something is X% percentage out of the whole.
For example, with the advent of Common Table Expressions (CTE), this makes it a whole lot easier to return all the data rows, along with the percentage in one single T-SQL pass.
Therefore, I am inviting you all to write about “data presentation” to the user. This can be in the form of T-SQL code, an SSRS report, etc. What can you do to streamline data presentation? I used a CTE, you can use one, but you don’t have to. No hard format, just be creative, and mention the importance of data presentation.
“This ugly hack is only temporary,” you think. Six months later, a coworker curses your name, sacrificing a chicken to any deity that will help expedite your getting struck down by lightning, a school bus, or both.
Crap code. We’ve all seen it. We’ve all created it. We’re all guilty. Yes, even you. Sometimes our crap is purposeful—the ugly, “temporary” hack. Sometimes we produce crap because we simply don’t know any better. But there is no excuse good enough. As professionals, we must strive to rid ourselves of bad habits. And the only way to learn the difference is to see lots, and lots, and lots of examples.
That’s where you come in. This month’s T-SQL Tuesday challenge: reveal your crap to the world. Why is (or was) it crap? Why did you do it? And how did you learn from your mistake?
What is the topic for July?
The topic for July is “T-SQL Best Practices”. If you work with SQL Server, then undoubtedly you would have had to write T-SQL queries atleast once or would have had to debug the seemingly useful piece of T-SQL code written by your developers to find out where the performance bottleneck or problem was. Your post for this month’s revolving blog party could be along one of the areas:
a. A set of T-SQL best practices that you follow in your shop that or you believe that should be followed always. It could be as specific as for writing only linked server queries or writing queries for SSIS packages etc.
b. An issue that you resolved because certain T-SQL best practices were not followed.
c. A workaround that you used (like query hints) to resolve an issue where T-SQL best practices couldn’t be implemented due to involvement of a third party solution.
Why did I choose this topic?
Over the years of troubleshooting SQL performance related issues, I have found on multiple occasions that the T-SQL query in question was performing badly because certain best practices for writing that piece of code were not followed and the one responsible for the development had not foreseen that such an oversight could become a bottleneck when the data or the number of users increased. So, I thought it would be a good idea to get the SQL Community’s thoughts around best practices in this area. Sometimes, the most obvious things are the easiest to overlook!
Its the first week of June and for those of us living along the Gulf and Atlantic coasts of the US, that brings the beginning of hurricane season. It also means its time for this months installment of T-SQL Tuesday.
This Months Topic
Disaster Recovery. This topic is very near and dear to me based on the fact that I live on a barrier island that was the site to the deadliest natural disaster in US history and more recently destroyed by the third costliest hurricane in history. Needless to say preparing for disasters is nearly instinctive to me which might explain why I’m a DBA but I digress. Anything you’d like to blog about related to preparing for or recovering from a disaster would be fair game, have a great tip you use to keep backups and recovers running smoothly, a horrific story of recovery gone wrong? or anything else related to keeping your systems online during calamity. We want to hear it!
This month’s topic is CTEs, or Common Table Expressions. Had you asked me 10 years ago what CTE meant, I would have replied “coefficient of thermal expansion” but that was back in my semiconductor & electronic materials phase. I like the database version much better 🙂
Have you ever solved or created a problem by using CTEs? Got a tip, trick, or something nifty to share? I’d love to see your posts about any of the above. Also don’t forget that T-SQL Tuesday is not limited to only T-SQL:
“Any post that is related to both SQL Server and the theme is fair game. So feel free to post about SSIS, SSRS, Java integration, or whatever other technologies you’re working with in conjunction with SQL Server. Even if your post includes no T-SQL we still want to see it.”
Site list, but invitation below from Matt Velic.
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!