T-SQL Tuesday #1: Date/Time Tricks

SQL Server, T-SQL
I'm going to try out Adam Machanic's idea for a blog party. The topic this month are Date/Time tricks. Instead of supplying a trick for Date/Time, I'm going to caution you about the tricks that you use. Let's take a simple issue. You want to pull back data from a table, let's use the Production.TransactionHistoryArchive in AdventureWorks2008, for a given month of data. Before we run the query, let's create an index on the table: CREATE INDEX ixTest ON Production.TransactionHistoryArchive (TransactionDate) The query itself is pretty simple. This is one mechanism that will retrieve the data for the month of July in 2003: SELECT tha.TransactionID FROM Production.TransactionHistoryArchive AS tha WHERE DATEPART(yy,tha.TransactionDate) = 2003 AND DATEPART(mm,tha.TransactionDate) = 7 In theory you should be able to use the index that was created earlier,…
Read More

Dr. DeWitt’s Key Note at the PASS Summit

PASS
If you missed this, here's your chance to make it up. If you were there, and like me, you need to rewatch it about six to eight times to try to understand everything that was presented, here's your chance. Dr. DeWitt's key note was probably the high point of the Summit or at least in the top 5. It's not to be missed.
Read More

SQL Standard Update

Misc
Andy Warren in the latest PASS Connector has posted an update on where we're at with the SQL Server Standard. I'm so happy that Andy has been keeping this out in front of people. It provides some impetus to get the work done. Except for the authors thanks (and they're receiving $500, so they should say thank you), there's very little feedback on the Standard to show whether or not people are interested, if the goals and ideas are worthy... In other words, you guys need to let us know what you think about the thing. Two more articles are in the hopper to be published. Another has gone into copy edit. We're technical editing two others. That's five more, so you guys can expect to see another ten weeks…
Read More

How do -You- use SQL Server

nHibernate, SQL Server, T-SQL, Tools, Visual Studio
I've been tagged by a misplaced yankee, uh, New Englander, whatever. The question is, how do I/we use SQL Server where I work. That's a tough one. It would make a much shorter, and easier, blog post to describe the things we don't use it for. However, keeping with the spirit of these tags, I'll try to lay out it. For those that don't know, I work for a rather large insurance company. This means that we have lots and lots of databases, but not much data. We also are cheap. That means we'll run an app into the ground rather than spend the money & time to replace it. We have apps still running from the 70's and 80's propped up by ancient men with pocket protectors, spit, bailing wire…
Read More

SQL Saturday #34/New England Data Camp v2.0

Misc
It's official sports fans. Well, it's been official since last week since Adam Machanic set up the web site. The New England SQL Server Users Group and the Southern New England SQL Server Users Group are again jointly hosting a full day of SQL Server goodness on January 30th. The call for sponsors and speakers is open. We already have several local luminaries lined up to present including Aaron Bertrand on Management Studio Tips & Tricks and Scott Abrants on Automating Database Deployments with Visual Studio. Please register to spend a day with your peers, learning and networking. It's being held at the Microsoft Waltham office, a great facility. We should have a full day with lots to do and learn.
Read More

SQL Server XQuery For Idiots

SQL Server, T-SQL
I'm still struggling with learning XQuery. My latest little revelation was small, but vital. The difference between: @inXML.nodes('/rss/channel/item') and @inXML.nodes('/rss[1]/channel[1]/item') Is the difference between a 10 minute query and a 4 second query. Kind of shocking really. My understanding is that XQuery assumes there are multiple possible paths that look like "/rss/channel" so it searches over and over again through the XML to see if it can find them. But by identifying it as a root, showing that only one possible path is available, it stops stumbling around in the dark and simply reads the data. It's a little thing, but it made an enormous difference. I've still got a long way to go in learning how to use XPath within XQuery. UPDATED: I modified the title so that it's…
Read More

Slow Blogging

Misc
Sorry, I've been travelling for three weeks and, except for the posts around the PASS Summit, I've been blogging very intermittently. I'm back in town, all travel done. The posts will pick up from this point forward.
Read More

Record of a PSS Call

Uncategorized
Not everyone has the opportunity to call Microsoft Premier Support. For those who have not yet had this experience, I'll document my most recent, non-critical, call. Critical calls are a different critter entirely. We were experiencing a very odd error on one server in our system. When a particular procedure was run with a particularly large set of data, it would produce an error, but only when called from the application. The exact same error with exactly the same data called from SSMS did not produce an error. We went through a very extensive set of tests and were unable to fix the problem on the server. After moving the production system that was experiencing the issue to a different server, we decided to contact PSS. 8:48 Am, Tuesday: I made the…
Read More

Proof

Misc
SQL Rockstar tells me that unless there are photo's, it didn't happen. Brad McGehee published some pictures from DevConnections. See, I really do try to get people to buy my book... uh, I mean present technical sessions at conferences. Note the laptop with the styling stickers from: SQL PASS SQL Batman (defunct) SQL Serverpedia SQL Server Central Thrive SQL Server Bible SQL AgentMan SQL Rockstar One of these things is not like the others...
Read More

I have a Tag

Misc
That's a Microsoft Tag. I'm not quite sure what exactly to do with it, but here it is. Evidently you're supposed to take pictures of it with your phone or something and it will lead you back here. I'll have try making a sticker out of it or something. Scary_DBA_Blog_200911172047
Read More