Links for the Week

GENERAL 7 Steps to Zap Your Creativity – Dumb Little Man shares tips for giving your creativity a quick pick me up. Some of it might be common sense, but it’s always good to get a refresher on what you can be doing to be more creative. Regardless of profession, creativity is a vital part…
Read More

Get First and Last Day of Month

Just a quick post with two T-SQL functions to compute the first and last day of the month for any DATETIME. These have been incredibly useful on a daily basis and I figured that I would pass them along. Keep in mind that these are inline scalar-value functions and will be evaluated for every row…
Read More

Mirroring table changes through DDL triggers

Let’s say that we have an application that tracks and reports customer bills. Customers are able to view reports based on their bill. As time goes on, the customers have a need to create adjustments to their bill. It should be simple enough to add some identifying data to the bill to determine which bill…
Read More

Links For The Week

SQL SERVER Scripting DBA Actions – Dan Jones (Microsoft SQL Server team member) has put together a great overview of his tips and techniques for automating DBA tasks. This comes as a direct result of sitting in on the panel discussion on automation from PASS. Summer Camp for DBA’s (#SQLPASS) is over for 2008 –…
Read More

Custom Sorting ArrayLists

A co-worker approached me with the problem of sorting an ArrayList of ArrayLists. Normally you might handle this in a DataTable or entity collection in your particular ORM. In this case, this was the data structure that was available to sort: [[sortorder][type][message] [sortorder][type][message] [sortorder][type][message]] Knowing a little bit about how ORM tools work, I made…
Read More

Creating Dynamic Where Clauses

Sometimes you just have to be able to dynamic search criteria in a stored procedure. What’s going to be the best way to accomplish this? You could use dynamic SQL and run the risk that you won’t have compiled execution plans, syntax highlighting, or readable SQL code. That’s not really an elegant solution. Let’s get…
Read More

Links for the Week

Brent Ozar provided the inspiration for this blog post and the others that will follow. Essentially, the goal is to put together a list of the most interesting/entertaining links that I’ve found in the last week. If you’re easily offended by SQL Server, I suggest you turn away now. 5 Quick Tips for the Query…
Read More

Avoiding Cross Database Ownership Chaining

Cross database ownership chaining is bad. Very bad. How bad? Despite being included in SQL Server 2005, this feature is disabled by default. SQL Server 2005 Books Online goes on to say “Setting cross db ownership chaining to 1 is not recommended unless all of the databases hosted by the instance of SQL Server must…
Read More

Cursing at cursors

Cursors. Many database developers have to suppress a shudder of horror when they open up a stored procedure only to find a cursor lurking inside. They certainly have their place in the database developer’s arsenal of tools, but they can usually be rewritten as an easily understood set operation. I’ve spent the first three days…
Read More

Get dates quickly with SQL

That’s right, now you too can use T-SQL to get dates quickly! Today at the client I came across the following chunk of SQL in a where clause: dateadd(m,-24,(cast(datepart(m,getdate()) as varchar(2))+'/1/'+cast(datepart(yyyy,getdate()) as varchar(4)))) It’s used to return the first of the month two years ago. So, for today, this would return 2006-09-01 What’s wrong with…
Read More
Menu