Blog ala Vidar

SQL, AppFrame and other cool technologies

Category Archives: Published

5 minutes interview #26 – Matthew Velic

About a year ago I saw a video with a guy entering a “SQL Cruise contest” on twitter. At first I thought it was a joke, but it was well made and it made me smile. After that I kept seeing @mvelic and started reading his blog. He’s active in the SQL community (both on twitter and in real life), and has written several good blog-posts.

So, who are you Matt?
I’m a just a guy, originally from Cleveland, OH, and now living and working in Washington, DC. I moved here during college: I majored in Fine Art. I built sculptures and did installations with video and websites and even yarn. After graduation I made the conscious decision to not starve to death, and so I laid down my tools and went to work. I temped around DC, as is fairly average for graduates, but I was a step ahead of most because I had worked while in college. Most of my experience was in fund raising support and office administration.

How did you end up as a DBA?
Well, that’s where the story gets interesting. My final temp gig landed me at the Elizabeth Glaser Pediatric AIDS Foundation. They needed help through a database conversion and when I showed some aptitude for that project, they hired me full time to do data entry and fund raising support. A little over a year into the position, the official DBA was let go and his database administration tasks fell to me. At first I really didn’t know what I was doing, but with the community’s help, I was able to overcome many of my shortcomings in a small timeframe.

How do you find time to be active in the community?
I won’t lie, it’s tough sometimes. There are nights (and weekends) where I want to pick up the Xbox controller rather than work on blog posts or troll the internet for new SQL Server resources. But I enjoy doing it. I like to write, and I like to teach, and I like to share what I find. I hope I can continually get better at all these things.
And I won’t claim to be unselfish either: sharing can be a career growing activity. But as I came from an untechnical, temp-job background, I’m so glad to have a career!

If you should pick one thing, what’s the best thing about an active community?
There are so many great things about an active SQL Server community. Based on where I’m at in my life right now, the Best Thing is the feeling of support and camaraderie. I’m a one-man shop covering our fund raising systems. But I have no support. No one to ask advice, kick around ideas, or make plans. Especially through Twitter, I can get this support from the community and it’s filled that vacuum.

What do you do when you’re not in front of your computer(s)?
There’s non-computer time? Lately I’ve been reading fiction again: finished The Book of Lost Things by John Connolly, The Magicians by Lev Grossman and working on Snow Crash by Neal Stephenson. If you couldn’t tell, I’m a bit of a sci-fi and fantasy nut. I’ve also been known to partake in strategic board games from time to time, and I do enjoy good food (home cooked or going out). And when things get heavy, I break out the acoustic.

Blog: http://mattvelic.com/
Twitter: http://twitter.com/mvelic

Advertisements

Moving to WordPress.com

It’s been a while since my last blog post, and one of the reasons is that I’ve used time to find out where to put my blog. Why move it from AppFrame.com you might ask. My main point is uptime. Omega is not a hosting-company; it’s a software-company. Therefore we don’t have the same uptime policies with 100%, 99.99% etc. Of course, some of our servers are high priority, but the point here is that we develop software which is hosted at the customer’s IT-department, at Rackspace.com or similar.

Lately the technology-department have been pushing out Web4 (our new Web framework), and this means testing it on all internal sites, including the blogs. I’m impressed by the framework, and I really like our CMS, but the “problem” is just that I don’t need any of these features. I just need my blog to work, and look awesome!

After deciding I didn’t need any AppFrame things for my blog, I started looking around for a suitable blog-engine. I’ve looked at blogger, WordPress and a couple of other alternatives. I’ve also set up a self-hosted WordPress-blog. My conclusion is that for MY needs, at the moment, WordPress.com is the best out there.

WordPress.com Pros

  • Very high uptime
  • Scaling – Since every blog “lives” on multiple servers, there’s no problem if my blog becomes extremely popular over night
  • After setting it up I don’t have to deal with updates, backups or any other maintenance
  • It’s free
  • Extra traffic
  • Standard blog – Easy to handle comments (from my iPhone)

WordPress.com Cons

  • Other than choosing themes, using widgets and stuff, there’s very limited customization
  • No plugin upload

My new URL is https://vidar.nordnes.me/. My RSS feed is still at http://feeds.feedburner.com/BlogAlaVidar. If you follow me from TeamDocuments/Connect, you might find my new blog there soon!

SQL Weekend

From left: Stian, Erik, Svein Even, Erik Martin, Vidar, Kai Roger, Jekaterina, Werner, Mauricio. (Photo: Werner Waage)

This weekend me and 9 others from my department had what we called a SQL Weekend. No, not Spa Weekend, but SQL Weekend. The goal was to learn as much as possible about SQL Server and start studying for the 70-433 (TS: Microsoft SQL Server 2008, Database Development) exam, but also to socialize. We arrived at Rica Maritim Hotel an hour after work and went straight to Naustet, which is the restaurant at that hotel, and had dinner. If you’re in Haugesund and want a good meal, you really have to go there. It was delicious!

After dinner we headed up to one of the meeting rooms we had ordered and started preparing for our talks the next day. The plan was that each person would pick a chapter in the book and have a presentation about it. My chapter was chapter 4; Using additional query techniques. I’ve already passed this exam, and my presentation was done WAY before this weekend, so I used my “spare” time to help the others preparing their sessions.

When we started getting tired of PowerPoint, we all went to the bar to have something to drink and socialize a bit. It’s nice to have some time chatting about something else just for a couple of hours.

Stian having his talk about SQLCLR and FileStream.

The next day (Saturday) started with breakfast at 08:00. Breakfast was, as the dinner the day before, one of the best meals I’ve ever had. After eating a bit too much we went to the meeting room to continue preparing for our presentations. A couple of hours later we Werner Waage started the show with having his session (chapter 1; Data Retrieval). Everyone followed him with their chapters. After a while it went for the sport in referring to my blog, so at the end Stian Skjerveggen topped it off with having a sexy picture of me in his slides.

To summarize this was an awesome weekend. Everyone learned a lot, loved the service from the hotel, the food was great and we got to hang out together. I’m really hoping we can do this again, and then maybe invite people outside our department. Anyone want to join? 🙂

If you click on the post title, you can download the presentations and demos.

Podcast Survey

Once again I’m thinking of starting a podcast and I’d like to hear your opinion. It would be very helpful if everyone could please answer these 4 questions. Thanks for your 30 seconds! NB! No registration, login or similar required!

Create your free online surveys with SurveyMonkey, the world’s leading questionnaire tool.

Buying my first Mac

Yes. I have sold my soul to the devil; Apple. After using Linux for several years, I got “forced” over to the Microsoft world after starting at Omega. I realized that Linux really wasn’t that great, so I stopped using it as my desktop. I still use it for servers sometimes, but I tend to prefer the Microsoft platform on servers too.

Last year I traded my HTC HD2 with an iPhone, and a couple of weeks ago I bought an iPad. These are the best products I’ve used in these categories (phone and tablet), so I figured I’d try out the Mac.

I think I’ll like it for some things, but I don’t think I’ll exchange my main desktop with a Mac. Even if I wanted to, I’m too dependent on Microsoft products like Management Studio and Visual Studio. I know you can run a virtual machine inside OS X, but what’s the point if you spend most of your day in that virtual machine anyways?

I’ve been trying to find a place where I “need” the Mac, because people kept telling me that spending 10.000 NOK just to test it out is stupid. Last week I found a use-case! I’ll use it to record music with my band, and as a TV-PC. So I went to Apple.com and ordered a Mac Mini, a wireless keyboard, the Magic Mouse, a Trackpad and a 1TB Time Capsule. I’m really looking forward to testing it out so be sure to check back in a couple of weeks for the second part.

The OVER clause

To use the ROW_NUMBER, RANK, DENSE_RANK or NTILE functions you need to use the OVER clause, but did you know you can use it on other functions as well? Like SUM, AVG, MAX etc. In the example under I want to list all timesheet records, but I want to know if the person has 7.5 hours each day, so I’ve made a “SumDailyManHours” column in the SELECT. This is easily done with SUM(ManHours) OVER (PARTITION BY PersonID, TimesheetDate). In the “old” days I’d do something like the second SELECT statement.

CREATE TABLE #Timesheet (
	PersonID NVARCHAR(8),
	ProjectID NVARCHAR(10),
	TimesheetDate DATE,
	ManHours DECIMAL(4, 2)
)

INSERT INTO #Timesheet
  (PersonID, ProjectID, TimesheetDate, ManHours)
VALUES
  ('Vidar', 'Customer1', '2010-12-01', 1),
  ('Vidar', 'Customer2', '2010-12-01', 5),
  ('Vidar', 'Customer1', '2010-12-02', 1),
  ('Vidar', 'Customer2', '2010-12-02', 6.5),
  ('Werner', 'Customer1', '2010-12-01', 7.5),
  ('Werner', 'Customer2', '2010-12-02', 7.5)

-- New way of doing it
SELECT
  *,
  SUM(ManHours) OVER (PARTITION BY PersonID, TimesheetDate) AS SumDailyManHours
	FROM #Timesheet

-- Old way of doing it
SELECT
  *,
  (SELECT SUM(ManHours)
		FROM #Timesheet
		WHERE PersonID = T.PersonID
		  AND TimesheetDate = T.TimesheetDate) AS SumDailyManHours
	FROM #Timesheet AS T

DROP TABLE #Timesheet

Here’s the result for both SELECT statements:

PersonID ProjectID TimesheetDate ManHours SumDailyManHours
Vidar Customer1 2010-12-01 1.00 6.00
Vidar Customer2 2010-12-01 5.00 6.00
Vidar Customer1 2010-12-02 1.00 7.50
Vidar Customer2 2010-12-02 1.00 7.50
Werner Customer1 2010-12-01 7.50 7.50
Werner Customer2 2010-12-02 7.50 7.50

Apple iPad

Tuesday this week (Nov. 30th), Apple released iPad to Norway. I once again had to discuss with myself whether or not to buy one for myself. My arguments were:

 

Pros

  • It’s a ”little laptop”, meaning that I can bring it where-ever I go and still have most of my things with me.
  • Angry Birds – yes, I’m addicted!
  • It has the best twitter client there is; TwitBird Pro, with support for Read it Later.
  • It’s got apps for more or less everything; spreadsheets, presentations, games and even RDP (Remote Desktop Protocol)!

Cons

  • Apple. I love their products, but hate their attitude and their fan-boys which take all criticism to Apple (or their products) personally.
  • I don’t really need it.
  • It’s not a full-worthy computer, so I can’t replace any of my computers with it.

 

As you probably figured out by now, I’m a gadget geek, so I went out and bought one on Wednesday. The one I went for were 16GB, with 3G. The reason for this is that I will probably not use it for media-stuff (music, video etc.), and the reason that I choose 3G were that I actually might use this when I’m at a customer. My handwriting is so horrible that I sometimes don’t understand my own writing. Now I can bring my iPad instead, and take notes on that, and even if I don’t get access to the customer’s Wi-Fi, I still got internet access via 3G.

Now, I’ve used it very heavily every day, playing games, watching videos (I love TED), taking notes in meetings, tweeting and lots more, and I love it. I really love it!

I think this is an awesome device, and I am going to recommend it to all of my family members. If you’re in the market for a new laptop, and you’re using it for Facebook, Internet bank, MSN and surfing, this is without a doubt a perfect device in my eyes. Note that Java, and flash, doesn’t run on it, so to do Internet banking, you need an app from your bank. Most of the popular banks in Norway already got apps, either for the iPhone (which runs on the iPad) or specially designed for the iPad (often called “HD version”).

Oh, and just to be clear. This isn’t a device created for developers. It’s created for the end user, like my mom. You can’t run Visual Studio on it. You can RDP to a server, but coding on a touch-screen? I wouldn’t do that at least.

 

At last I’ve got a list of apps you might want to check out:

  • Dropbox – Enables you to sync files between all your devices, including Windows, Mac, Linux, iPad, iPhone and Android.
  • TVGuiden – Norwegian TV Guide.
  • TwitBird Pro – The. Best. Twitter. Client. Ever!
  • Read it Later – Great “extension” to TwitBird, which enables you to read websites after tweeting.
  • Evernote – Sync your notes between all your devices.
  • TED – Ideas worth spreading. 3-20 minutes videos about new technology, thinking and more.
  • Spotify – Music streaming.
  • Kindle – Read your e-books on your iPad. Read my review on the Kindle here.
  • Air Video – Enables you to stream video from your home server.
  • Angry Birds – Addictive game.
  • Air Hockey – Fun two-player game.
  • Civilization Revolution – If you like the Civilization game series, you’ll love this!

SQL Server 2011 – Denali

Almost a month ago, Microsoft released the first CTP (Community Technology Preview) version of their upcoming SQL Server 2011, code-named Denali. I immediately downloaded and installed it on all my machines, and I’ve been using it ever since. It works perfectly with both 2005 and 2008, and of course with 2011.

Now, what’s new in this release? The biggest difference is that Management Studio is built into Visual Studio. Or, more correct, Management Studio has got a Visual Studio 2010-shining. I think this is a good call. For instance, I HATE the intellisense in 2008. It’s the first thing I remove when I’ve installed it, but in 2011, I haven’t turned it off yet, because it’s not in my way. It’s actually helping me write queries! The other big new UI related feature is snippets. Now you can, finally, have them inside Management Studio. I’m going to create a library of my scripts and make a snippet folder to share with all that’s interested. I’ll post it here on my blog when it’s ready.

When it comes to T-SQL enhancements, there’s actually a couple of new features that looks very interesting:

ORDER BY has some new features. With the following query, you get 10 rows. Not the first 10, but from row 10 (OFFSET 10) to 19 (FETCH NEXT 10). I think this will be easier to use for paging than using ROW_NUMBER() in 2008.

SELECT *
	FROM sys.sysobjects
	ORDER BY name
	OFFSET 10 ROWS FETCH NEXT 10 ROWS ONLY

Notice that in books online they specify that FETCH FIRST and FETCH NEXT are synonyms and that they’re there to provide ANSI compatibility.

CREATE SEQUENCE is a completely new T-SQL feature. The following query makes a sequence that you can poll.

CREATE SEQUENCE test
	AS INT
	START WITH 1
	INCREMENT BY 1

As you see, the script is not refering to any tables, which means you can use this sequence anywhere by using NEXT VALUE FOR MySequence. For instance:

INSERT INTO MyTable
  (Field1, Field2)
VALUES
  (NEXT VALUE FOR MySequence, 'Value2')

You can also use this feature as a default constraint. This could be helpful when identity-columns isn’t good enough.

SELECT TOP .. WITH TIES

Ever wanted to query a table and get all records that have one of the top 3 values? Let’s say you have a Sales-table where all your sales are stored. You want to find the top 3 sales, but you want to include “ties”. Let me show you with code.

DECLARE @Sales TABLE (
    Customer NVARCHAR(200),
    TotalSum FLOAT
)

INSERT INTO @Sales
  (Customer, TotalSum)
VALUES
  ('Statoil', 4000000),
  ('Hydro', 1000000),
  ('Kiwi', 100000),
  ('Mega', 100000),
  ('Ølen IL', 20)

SELECT TOP (3) WITH TIES
  *
    FROM @Sales
    ORDER BY TotalSum DESC

The results will be 4 rows:

Customer TotalSum
Statoil 4000000
Hydro 1000000
Kiwi 100000
Mega 100000

Pretty neat?

Use Hotmail with YOUR custom domain

Did you know you can use your custom domain in Hotmail, and with other Live services? A while ago, Microsoft “opened up” Hotmail to accept custom domains. You can do this by visiting http://domains.live.com . I’ve done this with my domain; nordnes.me. Now, http://mail.nordnes.me gets me to the hotmail login-form, where I log in with vidar@nordnes.me, and check my mail there. The great thing about this is that I no longer have to run my own exchange server, or worry about mail-things like spam or similar. Other interesting supported services are calendar, skydrives and photos. This makes it nicely integrated with my WP7.