Got a fun requirement today. Using SQL, the developer needed to convert an integer representing seconds into the format of dd:hh:mm:ss. So 125 seconds would be 00:00:02:05.
I put together a quick script that creates a table variable, inserts some test values, and selects back out of it.
DECLARE @ADAM TABLE(sec INT NULL) INSERT INTO @ADAM (sec) VALUES (125) INSERT INTO @ADAM (sec) VALUES (3600) INSERT INTO @ADAM (sec) VALUES (3605) INSERT INTO @ADAM (sec) VALUES (60000) INSERT INTO @ADAM (sec) VALUES (6000) INSERT INTO @ADAM (sec) VALUES (600) INSERT INTO @ADAM (sec) VALUES (86400) INSERT INTO @ADAM (sec) VALUES (86405) INSERT INTO @ADAM (sec) VALUES (172800) INSERT INTO @ADAM (sec) VALUES (172860) INSERT INTO @ADAM (sec) VALUES (172865) INSERT INTO @ADAM (sec) VALUES (1234567) INSERT INTO @ADAM (sec) VALUES (75654) SELECT RIGHT('0' + CONVERT(varchar(6), sec/86400),2) + ':' + RIGHT('0' + CONVERT(varchar(6), sec % 86400 / 3600), 2) + ':' + RIGHT('0' + CONVERT(varchar(2), (sec % 3600) / 60), 2) + ':' + RIGHT('0' + CONVERT(varchar(2), sec % 60), 2) FROM @ADAM Results 00:00:02:05 00:01:00:00 00:01:00:05 00:16:40:00 00:01:40:00 00:00:10:00 01:00:00:00 01:00:00:05 02:00:00:00 02:00:01:00 02:00:01:05 14:06:56:07 00:21:00:54
Brad McGehee is one of my more favorite authors of SQL literature. How to Become an Exceptional DBA is one of his more popular books. It’s really a career guide for novice and experienced DBAs, alike. It shows step-by-step methods for how to differentiate yourself from the crowd. Most of it is common sense, but it’s a good reminder for how to be an exceptional DBA.
You can download a free pdf version of this eBook here.
One of the blogs that I follow is the Business Of Software, by Neil Davidson. Neil is the co-founder and joint CEO of Red Gate Software and the organizer of the Business of Software conference. Back in October, Neil released a free eBook, Don’t Just Roll the Dice. It’s a useful, short book on how to price software. It includes theory, practical advice and case studies so that software pricing isn’t a roll of the dice.
37signals is one those companies that you just can’t help but notice. And once you do, you won’t be able to keep from following them and their philosophies. They are the guys that invented Ruby On Rails. They follow the strict mantra that software products should be built with the least number of features possible. Getting Real: The smarter, faster, easier way to build a successful web application is a new book written by the crew at 37signals.
Last week, one of our developers asked us in the DBA group what our standard was for currency columns. My first thought was DECIMAL(19,4), but I couldn’t give a reason why it was standard. I knew MONEY was essentially the same definition, but had heard that it was dangerous to use. Suspecting a rounding issue, I began with a simple test.
DECLARE @dOne DECIMAL(19,4), @dThree DECIMAL(19,4), @mOne MONEY, @mThree MONEY SELECT @dOne = 1, @dThree = 3, @mOne = 1, @mThree = 3 SELECT @dOne / @dThree * @dThree AS DecimalResult, @mOne / @mThree * @mThree AS MoneyResult DecimalResult MoneyResult 1.
I have been really getting into RSS feeds lately and have subscribed to alot of ones that interest me. I personally have been using the Google Reader on the iGoogle homepage. It’s a neat way to keep tabs on my varied readings. One that caught my eye was a challenge by Pinal Dave. Pinal challenged his readers to solve a puzzle that would return the size of each index for a speficied table.
When adding a new column with a default constraint to an existing table, keep in mind what you want your existing records to contain. If you add the new column and set it to be allow nulls, then all of the existing records will contain a NULL, and any inserted records will have the default value. However, if you set new column’s nullability to be NOT NULL, then the existing records will get back-filled with the default value.
Yesterday, my 5-yr old son, Logan, and my step-father-in-law, Jerry, and I went to play golf … in November! Being in the hign-60’s, it was just TOO nice of a day to not take advantage of it. Logan really has a surprisingly good tee-shot. He made it on the green with one tee-shot and chipped one in from 15-ft away in the rough! Pretty stinking amazing for a kid that doesn’t get to play too much.
Today, I got to go play in the fall leaves with my family out at the Nature Center. What a great day! We are still having awesome weather and the leaves are perfect right now. We even got to actually watch them fall from the trees. The kids ate it up! It was Suzanne’s idea to go take them out. In the past years, we never needed to go somewhere to experience leaves.
Recently, I had the opportunity to brush up on my SQL Server memory tuning skills. It’s been a while since I needed them, but I thought I’d throw out what I used for someone else’s future benefit.
First, some background knowledge: There are different physical memory limits for each Windows release. The virtual address space (set of virtual memory addresses) is limited to 4 GB for 32-bit Windows. The virtual address space is divided into two 2 GB partitions: one for use by the processes and other reserved for use by the system.