Grouping and Rounding Dates

Ever need to group dates and round them to intervals?  I had this exact need for a report on wait stats I was working on for an upcoming post.  I wanted the flexibility to be able to group a list of dates by either minute, hour, date, etc.  And then also round those dates within … Continue reading Grouping and Rounding Dates

Please, no TRIM()?

A couple weeks back I was asked “How come Microsoft has yet to put TRIM() in SQL?” I don’t really know why there isn’t a TRIM() function in SQL Server. There is an LTRIM for function removing leading spaces. And an RTRIM function for removing trailing spaces. But there isn’t a TRIM function. Let’s be … Continue reading Please, no TRIM()?

Checking EXISTS – What’s Your Practice?

Michael Swart (Database Whisperer) posted a great write up and interview with Brad Schulz that is worth checking out.  Michael’s post links to a post from Brad on the use of EXIST and what is required for the SELECT portion of the statement.  Hope you are still with me. Definitely worth the read and +1  … Continue reading Checking EXISTS – What’s Your Practice?

Scripting Object Level Permissions

A while ago while making changes to a client database, I needed to determine all of the object level permissions that were in the database I was working on.  The system stored procedure sp_helprotect turned out to be pretty useful in obtaining this information.  The procedure accepts four parameters: They do pretty much what would … Continue reading Scripting Object Level Permissions

Last Time SQL Server Restarted

Not a really hard thing to figure out, but for some crazy reason I always forget.  So, hopefully actually writing it out for the world to see will help me remember. Since tempdb is created every time that SQL Server restarts, the created date for that database can be used to determine the last time … Continue reading Last Time SQL Server Restarted