Skip to content
Jan 18 12

Oklahoma City JavaScript Group

by Rob

A new user group is starting in Oklahoma City and it is one I find
completely fascinating... a Javascript group! With the monumental surge in popularity of Javascript over the past year or so, this type of group is a can't miss.

Who should attend you might ask? All of us in the tech field because it is pretty much everywhere now. Even a database douche bag like myself is attending because I have finally accepted that Javascript is inescapable. Javascript is all over the web, going to be all over the desktop with Windows 8, appearing in the mobile markets, and starting to take over the back end with rad technologies like NodeJS.

I'm a complete noob with Javascript and I feel completely comfortable coming to this group because with as fast as this technology is moving, we're all noobs and need to learn from each other. This group will not waste your time because

Learning is cumulative.

As a speed freak, my primary interest lies in NodeJS, but I know for a fact that I will learn something to help me with Node from Vance talking about BDD testing with a testing framework called Jasmine. That is just how it works. He gives, I take, and down the road I give back. Even if you don't know or care a thing about Javascript, it can be a good networking opportunity with some of the people in our community that have a true passion for tech and are trying to push tech boundaries. If that doesn't interest you, you can lurk in the back and watch me ask stupid questions as I try and get the info to the highly firewall'ed learning center that is my brain... or just show up for a free lunch. You have options.

If you don't go or don't plan to go...no worries. I'll still love you (as a friend), but in our very fluid industry, dropping an hour a month of your time on something like this is an incredibly way to not go stagnant.

The first meeting is January 24th from 11:30-12:30 at the OKC CoCo. Come say hi and most importantly.... help me learn this stuff!

For more information, hit up http://okcjs.com/

Dec 16 11

Simple-Talk – SQL Test write up

by Rob

I had the pleasure of being able to write up a delightfully ephemeral piece on SQL Test for Simple-Talk. This is a fun little tool and I'm anxious to see just how much David and his team can improve it.

http://www.simple-talk.com/sql/sql-tools/sql-test-seeing-red-change-to-green/

In other news, being published on Simple-Talk is also another thing Troy Hunt won't be able to 1-Up me with.

Nov 20 11

Getting started with Postgres and MVC3

by Rob

"Postgres? WTF man, you're a SQL Server DBA!" It's true, I am a SQL Server DBA but even I have to admit that the Postgres team is doing some wildy exciting stuff. With that in mind, lets take a quick look at just how quickly we can replace SQL Server with a free/open full bore Enterprise database system like Postgres.

One of the first things you will notice is Postgres is way easier to install than SQL Server. The SQL Server install is born from a truck stop romance between TFS and Sharepoint that someone found in a garbage bag in a dumpster and burned to a DVD. Postgres takes a different angle and opts for a 'less is more' type of approach. One of the big things you will want to pay attention to is the password you give the default 'postgres' account. Think of him as the SA account in SQL Server as he too wields a mighty big stick.

Once we finish the installer, lets open up pgAdmin III (henceforth known as pgAdmin). If you are accustomed to SSMS with SQL Server and always wished it went on a diet... then you might like pgAdmin. Be warned though, pgAdmin isn't SSMS on a diet... it is like SSMS with Anorexia. Once pgAdmin is opened and you are connected, then drill down to 'databases' and do a 'new database' and use the GUI to make your fancy new demo database, or just run the raw sql:

 
CREATE DATABASE "Demo"
  WITH ENCODING='UTF8'
       OWNER=postgres
       CONNECTION LIMIT=-1;
 

Next, lets hop in that database and throw up some tables/data:

 
CREATE TABLE "Colors"
(
	colorid serial NOT NULL,
	colorname character varying(50) NOT NULL,
	constraint pk_colorid PRIMARY KEY (colorid)
)
WITH (OIDS=false);
 
INSERT INTO "Colors" (colorname)
VALUES ('red');
INSERT INTO "Colors" (colorname)
VALUES ('blue');
SELECT * FROM "Colors";
 

So why the quotes around the table names you might be asking... well, SQL Server has a bit of Honey Badger approach to what case you assign names and Postgres treats it like a pretty big deal. Luckily, overcoming it isn't a big deal, we just double quote it. Now, if you don't have years of tsql or camelcasing drilled into your brain, you can easy just do everything in lower case and not fight the double quote dragon.
What else sticks out there... oh Data Types! You will have to adjust to some variance in data types, but in a good way. Postgres has a lavish assortment of data types for you to fall in love with and one of which is using 'serial' instead of the whole IDENTITY(1,1) you might be used to in SQL Server. There are also some really cool things called Sequences in Postgres which are blazing fast and give you the value of the ID before you insert it. DBAs like them because it can get you AppDevs away from fatty GUID primary keys.

Fire up a new MVC3 app and hop into the Nuget console. From there, we're going to add our Postgre provider with "Install-Package Npgsql". Now that we have our vital provider assemblies, lets go mess around in the web.config.

 
<configuration>
	<system.data>
		<DbProviderFactories>
			<add name="Npgsql Data Provider"
        invariant="Npgsql"
        support="FF"
        description=".Net Framework Data Provider for Postgresql Server"
        type="Npgsql.NpgsqlFactory, Npgsql, Version=2.0.11.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />
		</DbProviderFactories>
	</system.data>
 
	<connectionStrings>
		<add name="pg" connectionString="Server=127.0.0.1;Port=5432;Database=Demo;User Id=postgres;Password=dontusethisaccount;CommandTimeout=20;" providerName="Npgsql" />
	</connectionStrings>
 

Yeah! We have our provider factory rocking and our connection string. Yes, I am using the postgres account in this demo and yes that is wrong/stupid, but I'm having so much fun playing with the Postgres engine that I decided to take a shortcut there for this entry.

So our color app is pretty quick and dirty. In keeping with that spirit, I'm going to use Massive as my ORM of choice. It already has a Postgres version ready to go. PetaPoco has some very nice Postgres options in it, but Massive is very quick/easy and the Expandos makes all the strong-typers uncomfortable and I love a good code-trolling.

In the Model folder of our app, I create a new class file called Massive and I copy/paste the Postgres version into it, and I also created a new class file called "Colors" that I pasted the following in:

 
	public class Color : DynamicModel
	{
		public Color() : base("pg", "Colors", "colorid") { }
 
	}
 

All wired up! In the home controller, we'll throw some code to play with our table in:

 
var table = new Color();
var colors = table.All();
ViewBag.colors = colors;
 

And then in our view:

 
@foreach (var color in ViewBag.colors)
{
	 @: @color.colorid @color.colorname
}
 

F5 and what do we get? BOOM!!! "Error 42P01: relation "colors" does not exist"
So remember when I started our Colors table with a capital C? This is where it can come back to bite you... and also one of the reasons I absolutely love Micro-ORMs. Fast, malleable, and so easy a DBA can use it. Let's hop into Massive and throw some quotes around our table access:

 
string sql = limit > 0 ? "SELECT TOP " + limit + " {0} FROM \"{1}\" " : "SELECT {0} FROM \"{1}\" ";
 

and Viola! It works! In pretty much the time it takes to install SQL Server, we're already rocking our stunning and highly valuable colors app!

Jul 26 11

Rock out with your Procmon out

by Rob

If you are not a fan of Sysinternals tools then you clearly do not have your geek merit badge. While I have always kept a local copy in the past, there is now a cool and easy way to get to Sysinternals and it is via
Start + run + \\live.sysinternals.com\tools

If you are already a gigantic nerd like me and have various login scripts that run, it is way easy to simply map that share by throwing the following into your login scripts:

net use s: \\live.sysinternals.com\tools

Jul 21 11

OSX Tools I use

by Rob

Misc:
ClamXav - antivirus
Evernote - for note taking
Handbrake - for media conversion
LibreOffice - for working on office docs... though starting to use Keynote for presentations
Onyx - mac maintenance app
VLC - for watching media on the mac
Transmission - for bittorrent

Internet:
Adium - for XMPP and stuff
Colloquy - for IRC
CyberDuck - for FTPness
Firefox - for browsing
Opera - for fast browsing
Skype
- Call Recorder - for recording Skype calls

Dev:
Mono - because I'm a C# hack
RubyMine - to help me feel less bad at Ruby
TextMate - Editing things
VMWare Fusion to virtualize things

Jun 29 11

Why Red Gate and I are friends with benefits

by Rob

What a great link bait title right? The purpose of this post is to give my reasoning for joining the Friends of Red Gate program. So without further ado:

Education - I simply love software development with all my heart. Much of this love is channeled towards learning. In the SQL Server arena there are a couple resources that just stand out above the others... I'm talking about SQL Server Central, Simple-Talk, the wealth of information that Brad McGehee(blog | twitter) puts out, Grant Fritchney(blog | twitter), and the various books. It became quite apparent that a lot of what has made me such a successful DBA is because Red Gate shares that same passion for building great software.

Community - Another manifestation of this love shows itself in community events. Whenever I put on an event or attend one, there is one company I know of that consistently steps up to the plate. Red Gate. Even during slower economic times, when some sponsors required coaxing and justification, when it came to community, Red Gate was always on board. While they are a company and these events are advertising or promotional opportunities, that aspect of it never comes on. No matter how big or how small the event, I always feel like they genuinely want all of us to learn and be better at our craft. I have a tremendous amount of respect for that company on this alone.

Tools - When I first downloaded and installed the beta of SQL Source Control, my knees became weak. In the chaotic world of database change management and DDL triggers, this tool absolutely blew my mind. When I started playing with this tool, it was like I had just won a lifetime supply of pizza and cupcakes. Everyone has schema/data compare tools or backup tools, but a native source control tool? Way to step up to the plate Red Gate. I wanted to email customer support and ask for SQL Source Controls ring size because I was hooked. We use TFS at work, but on the side I use a combination of Subversion and GIT... SQL Source control doesn't even care - it just does its job. The quality, ease of use, and the need that tool fills made me think that Red Gate loves software development just as much as I do.

I am not a salesman and I don't try to be. I'm not trying to sell you Red Gate tools. All I can do is tell you how they have worked for me and let you make the best decision for your situation. One message I do hope I convey is that the next time you are at an event that Red Gate sponsors or take advantage of any of their various learning resources, take a moment to thank them. They do a lot of things in front of and behind the scenes to help all of us reach success without any of us being forced to buy their tools and I find that amount of passion in a company both admirable and rare.

Friends of Red Gate

Jun 4 11

Tekpub – Full Throttle with Rob Sullivan show notes

by Rob

The question emails are starting to pile in (which is a good thing!) so this post is basically a way to centralize links/answers. In the show, I say a few times "we'll see this later" (like with SQL Server Profiler) and we never see it... that was mostly my fault. For some reason I kept thinking I would be able to squeeze 5 hours of content into 1 hour and was wrong. If there are aspects of SQL Server that you would like to see more of, as well as real world problems that you may have and would like to see solutions to, then let Tekpub know. We'll see if we can hack out real world solutions wrapped in a warm blanket of statistics and opinion.

Questions:
How do you get the stats to appear in the "messages" window?
Those stats come from the following commands:
SET STATISTICS IO ON;
SET STATISTICS TIME ON;
If you don't want to turn it on for every query/window, you can do what I do and set them to always be on in Management studio, you can do this by :
Tools -> Options -> Query Execution -> SQL Server -> Advanced
then check:
SET STATISTICS IO ON;
SET STATISTICS TIME ON;

Lock Pages in Memory, is that always good?
No, and perhaps I glossed over that section too much or technology changes too fast. While Lock Pages in Memory can be a wonderful setting, there are of course times when it can be pretty bad. You can read more about that here: http://sqlserverperformance.wordpress.com/2011/02/14/sql-server-and-the-lock-pages-in-memory-right-in-windows-server/

Why no filtered index on Posts?
In our first scenario, to get the front page up... we just went with the index that the engine suggested.. That got us up and running which is great, but there is room for improvement. To me, filtered indexes are more of a business rule decision and with enough time, if we saw that the load was heavy and predictable enough, we would have likely thrown a filtered index to satisfy the front page query.

What were you using for "Intellisense" in management studio? I am not extremely big on intellisense in general, however, I am kind of big on formatting and having a variety of administrative snippets at my finger tips. I use a 3rd party tool called Red-Gate SQL Prompt and have it moderately customized. Keep in mind, I really only use this type of product on data sets I am not very familiar with like the one in this demo. On datasets that I know pretty well, I find intellisense to really just get in the way and make me angry.

And the database? I am still working on a way to make the DB available. It is roughly 40GB raw, and 4GB compressed. If having the data is a big deal to you, hit me up on email and we can work something out (S3,FTP, yada yada yada)

Tech used in the series:
Visual Studio 2010 / MVC3 / EF 4.1
SQL Server 2008 R2 / Management Studio
Red Gate SQL Prompt "Intellisense" and "snippets" in Management Studio
SQL Sentry Plan Explorer The fun/effective way to view execution plans
EF Profiler The SQL Server friendly way to profile EF
CPU-Z A tried and true hardware enthusiasts way of checking hardware specs.

Source code: https://github.com/DataChomp/StackOverFaux

Apr 25 11

Windows Server Core – basic operations

by Rob

This post will basically be a collection of some of the crap I use while working on Windows Server 2008 R2 Core edition.

Quick tool to handle basic configurations like computer name/updates/time:
sconfig.cmd tool

Apr 14 11

Massive and using multiple args:

by Rob

So, in Rob Conery's example of using multiple args in a query

 
var tbl = new Products();
var products = tbl.All(where: "CategoryID = @0 AND UnitPrice > @1", orderBy: "ProductName", limit: 20, args: 5,20);

It makes the args appear to be this completely bad ass and intelligent command that knows exactly when and where to parse/apply the values. Well, in the real world versions of Massive the compiler doesn't take to kindly to that sort of syntax.

args: is a parameter of type object [] so the way I use multiple params is as follows:

 
object[] queryargs = {"Okapi", "online"};
var DBBasics = table.All(where: "WHERE ServerName=@0 and status = @1", args: queryargs );
 

and low and behold the magic happens.

Apr 7 11

Default backup compression in SQL Server

by Rob

I always forget this so it is going in a blog for quick reference:

 
SP_CONFIGURE 'show advanced options',1
RECONFIGURE WITH override
GO
SP_CONFIGURE 'backup compression default',1
RECONFIGURE WITH override
GO