Press "Enter" to skip to content

Select Indistinct

Using to create Flame Graphs for SQL Server Profiler, Extended Events, and more

A friend of mine was recently discussing using Flame Graphs in a project of his, and it inspired me to see how I could abuse the format to present a visual model of SQL execution.

Originally I had thought of building my own interface, but apparently the author of the above site also maintains a great repo which allows you to skip some of the more difficult steps:

There is a lot of detail there about profiling software with specific tools and how to convert their output to something the tool understands, but at its core the “folded” format is fairly easy to target and if you are fine with some text manipulation you can produce your own FGs and re-use the SVG generation, search, and zoom components of this tool.

What’s the format?
It doesnt take too much effort to suss out from flamegraph’s source:
# frame in the stack is semicolon separated, with a space and count at the end
# of the line.

Script for non-production restores

This is some code came together as a result of straightforward requirements; a team needed to spend a significant amount of time doing manual restores, and were tired of the GUI nonsense from SSMS. But also wanted some basic flexibility due to the fact that the servers configuration may change significantly (but not during the restore.)

The code makes some assumptions:
* Assumes your SQL service account has access to the file location for the backup
* You have the permission to create new databases and select from sys.master_files (CREATE DATABASE, ALTER ANY DATABASE, or VIEW ANY DEFINITION.)

Dirty tricks in SSRS authentication

Configuring SSRS authentication to IIS can be a pain, here are some things I have done in a pinch, and almost all of them are terrible, but if you repeatedly get a 401 unauthorized with SSRS, these might be able to help.

SSRS native mode on one domain, IIS on another – DMZ

In this mode, you are normally advised to implement basic authentication, and just pass a username and password in… in some instances you may be unable to use basic, and are forced to use NTLM.

In this situation a simple method to bypass this is to create a local user on both boxes with the same password, and have that user be the one the report server grants access to, and which user is running the web server process.

Make sure this password is strong, and doesn’t change.

SSRS native mode, same domain, IIS running as local system

In some cases you may find that the system is configured to run the IIS process as local system (generally not recommended). If this is the case, you can actually grant the entire computer name in the report server permissions via its hostname and a dollar sign.



Additional Troubleshooting for Native Mode

  • Enable the HTTP log for the report server , it can help enormously to isolate what’s being accessed, where, when, and sometimes who.
  • Double check each report folder in the hierarchy’s permissions for your user, while you may think you have permission, its quite possible you don’t and that someone overrode the parent permissions.
  • If you get a FORBIDDEN message instead of an unauthorized, the user you are trying to run the report as may need escalated permissions on the SSRS application directory itself (on the SQL Server).
  • When all else fails you can grant Browser permission to “Everybody”, but be aware that means anyone can request information from your reports, and is a really really really bad idea. (If it doesn’t work, that means you are not even making the request from the same domain)

Running SQL Queries On Multiple Servers At Once Using Registered Servers In SQL Server Management Studio

I just came across a situation where I was looking at long running queries across a few production servers, I wanted to quickly and easily run my query across them all to make sure that I wasn’t missing a problem on each server where a user had left a specific query for a looong time.

Thankfully, registered servers is here to the rescue! Many people using SSMS have never even used registered servers, and if they have, they dont know about this secret context menu hiding in the GUI.

What’s a registered server?

A registered server is effectively a way to remember that you have connected to a server, and allow easy access to connecting to it again. (There is probably a MUCH more technical explanation, but this one suffices. (Want more? Check the “BOL”:page)

In SSMS you can simply right click any active server and select “Register” to bring up the prompt to register the server. If you are running more than one set of servers that should be running different queries, then you may want to create additional server groups (when we get there).

In SSMS 2008, you can simply use the shortcut CTRL+ALT+G or select “Registered Servers” under the View menu.

Once that is complete, you should be able to right click any group you have created, and select “New Query”.

When you run your query, you should notice that an additional column exists now, with the label of the server that returns the query results.


Learn More

Popular Music For My Classes

This is some of the music I play for my classes, honed over a while.

Playlist 1:

|Name_____________ |Artist__________|Album_____________|
|Flashback|Kavinsky|1986 Vinyl|
|Testarossa (SebastiAn Remix)|Kavinsky|1986 Vinyl|
|Wayfarer|Kavinsky|1986 Vinyl|
|Dead Cruiser|Kavinsky|1986 Vinyl|
|Grand Canyon|Kavinsky|1986 Vinyl|
|Tacobel Canon|Ratatat|Classics|
|Loud Pipes|Ratatat|Classics|
|Bar Rumba|Mo’ Horizons|Elemental Chill – Volume 4|
|The Crossing|Soundtrack|Gattaca|
|It Must Be The Light|Soundtrack|Gattaca|
|Irene & The Morrow|Soundtrack|Gattaca|
|Second Morrow|Soundtrack|Gattaca|
|Not The Only One|Soundtrack|Gattaca|
|The Truth|Soundtrack|Gattaca|
|Call Me Eugene|Soundtrack|Gattaca|
|Impromptu For 12 Fingers|Soundtrack|Gattaca|
|I Thought You Wanted To Dance|Soundtrack|Gattaca|
|Now That You’re Here|Soundtrack|Gattaca|
|The Arrival|Soundtrack|Gattaca|
|The Morrow|Soundtrack|Gattaca|
|Further And Further|Soundtrack|Gattaca|
|Only A Matter Of Time|Soundtrack|Gattaca|
|The Departure|Soundtrack|Gattaca|
|Up Stairs|Soundtrack|Gattaca|
|God’s Hands|Soundtrack|Gattaca|
|A Borrowed Ladder|Soundtrack|Gattaca|
|Irene’s Theme|Soundtrack|Gattaca|
|The Other Side|Soundtrack|Gattaca|
|Becoming Jerome|Soundtrack|Gattaca|
|The One Moment|Soundtrack|Gattaca|
|Yourself For The Day|Soundtrack|Gattaca|
|Mi Viejo|Ratatat|LP3|
|Falcon Jab|Ratatat|LP3|
|Mumtaz Khan|Ratatat|LP3|
|Gipsy Threat|Ratatat|LP3|
|Black Heroes|Ratatat|LP3|
|En Focus (feat. Trinidad)|Quantic|Mishaps Happening|
|Perception|Quantic|Mishaps Happening|
|Sound Of Everything (feat. Ali|Quantic|Mishaps Happening|
|Mishaps Happening|Quantic|Mishaps Happening|
|Furthest Moment|Quantic|Mishaps Happening|
|Trees and Seas|Quantic|Mishaps Happening|
|Use What You Got (feat. Sonny|Quantic|Mishaps Happening|
|Angels and Albatrosses|Quantic|Mishaps Happening|
|Prelude To Happening|Quantic|Mishaps Happening|
|Don’t Joke With A Hungry Man (|Quantic|Mishaps Happening|
|When You’re Through (feat. Spa|Quantic|Mishaps Happening|
|Scavenger|Redial|MOS Mashed 4|
|Toothache Epiphany|nonfinite|Northbridge|
|Seventeen Years|Ratatat|Ratatat|
|El Pico|Ratatat|Ratatat|
|Spanish Armada|Ratatat|Ratatat|
|Breaking Away|Ratatat|Ratatat|
|Desert Eagle|Ratatat|Ratatat|
|Germany To Germany|Ratatat|Ratatat|
|Mr Oizo Autodrive T42|Kavinsky|Teddy Boy EP|
|Testarossa Nightdrive|Kavinsky|Teddy Boy EP|
|Transistor|Kavinsky|Teddy Boy EP|
|The Crash|Kavinsky|Teddy Boy EP|
|Arpanet Nightdrive (rework)|Kavinsky|Teddy Boy EP|
|Testarossa Autodrive|Kavinsky|Teddy Boy EP|
|Ghost Transistor|Kavinsky|Teddy Boy EP|
|The Grand Staircase|Port Blue|The Airship|
|In the Control Car|Port Blue|The Airship|
|Into the Gymnasium|Port Blue|The Airship|
|The Axial Catwalk|Port Blue|The Airship|
|Of the Airship Academy|Port Blue|The Airship|
|Up Ship!|Port Blue|The Airship|
|Sunset Cruiser|Port Blue|The Airship|
|Over Atlantic City|Port Blue|The Airship|
|The Gentle Descent|Port Blue|The Airship|
|Under the Glass Observation Dome|Port Blue|The Airship|
|An Enchanted Evening|Port Blue|The Albatross EP|
|City of Safe Harbors|Port Blue|The Albatross EP|
|Silver Blueberry|Port Blue|The Albatross EP|
|Of Japan|Port Blue|The Albatross EP|
|The Power Is On|The Go! Team|Thunder, Lightning, Strike|
|Friendship Update|The Go! Team|Thunder, Lightning, Strike|
|Junior Kickstart|The Go! Team|Thunder, Lightning, Strike|
|Huddle Formation|The Go! Team|Thunder, Lightning, Strike|
|Ladyflash|The Go! Team|Thunder, Lightning, Strike|
|Everyone’s a V.I.P. to Someone|The Go! Team|Thunder, Lightning, Strike|
|Panther Dash|The Go! Team|Thunder, Lightning, Strike|
|Get It Together|The Go! Team|Thunder, Lightning, Strike|
|Feel good by Numbers|The Go! Team|Thunder, Lightning, Strike|
|What Else Is There|NULL|Royksopp|

Playlist 2:

|It Was …|Lemon Jelly|’64-’95|
|’88 aka Come Down On Me|Lemon Jelly|’64-’95|
|’68 aka Only Time|Lemon Jelly|’64-’95|
|’93 aka Don’t Stop Now|Lemon Jelly|’64-’95|
|’95 aka Make Things Right|Lemon Jelly|’64-’95|
|’79 aka The Shouty Track|Lemon Jelly|’64-’95|
|’75 aka Stay With You|Lemon Jelly|’64-’95|
|’76 aka The Slow Train|Lemon Jelly|’64-’95|
|’90 aka A Man Like Me|Lemon Jelly|’64-’95|
|’64 aka Go|Lemon Jelly|’64-’95|
|One|Ratatat|9 Beats|
|Two|Ratatat|9 Beats|
|Three|Ratatat|9 Beats|
|Four|Ratatat|9 Beats|
|Five|Ratatat|9 Beats|
|Six|Ratatat|9 Beats|
|Seven|Ratatat|9 Beats|
|Eight|Ratatat|9 Beats|
|Nine|Ratatat|9 Beats|
|The Birth and Death of the Day|Explosions in the Sky|All of a Sudden I Miss Everyone|
|Welcome, Ghosts|Explosions in the Sky|All of a Sudden I Miss Everyone|
|It’s Natural to Be Afraid|Explosions in the Sky|All of a Sudden I Miss Everyone|
|What Do You Go Home To?|Explosions in the Sky|All of a Sudden I Miss Everyone|
|Catastrophe and the Cure|Explosions in the Sky|All of a Sudden I Miss Everyone|
|So Long, Lonesome|Explosions in the Sky|All of a Sudden I Miss Everyone|
|Sleep Deprivation|Simian Mobile Disco|Attack Decay Sustain Release|
|Fourteen drawings|Helios|Caesura|
|A mountain of ice|Helios|Caesura|
|One|Aimee Mann|Cinematic Treatment|
|Loud Pipes|Ratatat|Classics|
|Tacobel Canon|Ratatat|Classics|
|Tank !|Cowboy Bebop|Cowboy Bebop OST|
|Something|The Willowz|Eternal Sunshine of the Spotless Mind|
|Yo Pumpkin Head|Cowboy Bebop|Future Blues|
|Central Plains|Carbon Based Lifeforms|Hydroponic Garden|
|Tensor|Carbon Based Lifeforms|Hydroponic Garden|
|MOS 6581 (Album Version)|Carbon Based Lifeforms|Hydroponic Garden|
|Silent Running|Carbon Based Lifeforms|Hydroponic Garden|
|Neurotransmitter|Carbon Based Lifeforms|Hydroponic Garden|
|Hydrophonic Garden|Carbon Based Lifeforms|Hydroponic Garden|
|Exosphere|Carbon Based Lifeforms|Hydroponic Garden|
|Comsat|Carbon Based Lifeforms|Hydroponic Garden|
|Epicentre (First Movement)|Carbon Based Lifeforms|Hydroponic Garden|
|Artificial Island|Carbon Based Lifeforms|Hydroponic Garden|
|Refraction 1.33|Carbon Based Lifeforms|Hydroponic Garden|
|The Pulse|Digitalism|Idealism|
|The Bachelors Remix|RJD2|In Rare Form|
|Big Game|RJD2|In Rare Form|
|Explosive|RJD2|In Rare Form|
|Fuck A Soundcheck|RJD2|In Rare Form|
|Incorporate Anthem|RJD2|In Rare Form|
|Inhale Remix|RJD2|In Rare Form|
|Kill ’em All Remix|RJD2|In Rare Form|
|Mic Control|RJD2|In Rare Form|
|One Day|RJD2|In Rare Form|
|Rocket Science|RJD2|In Rare Form|
|Saliva|RJD2|In Rare Form|
|Seven Light Years|RJD2|In Rare Form|
|The Takeoff|RJD2|In Rare Form|
|Under the Hammer|RJD2|In Rare Form|
|Unlimited|RJD2|In Rare Form|
|Up to No Good Again|RJD2|In Rare Form|
|Uprock|RJD2|In Rare Form|
|Weatherpeople|RJD2|In Rare Form|
|Nervous Tension|Lemon Jelly|Lemonjelly.KY|
|A Tune For Jack|Lemon Jelly|Lemonjelly.KY|
|His Majesty King Raam|Lemon Jelly|Lemonjelly.KY|
|The Staunton Lick|Lemon Jelly|Lemonjelly.KY|
|Homage To Patagonia|Lemon Jelly|Lemonjelly.KY|
|Kneel Before Your God|Lemon Jelly|Lemonjelly.KY|
|Page One|Lemon Jelly|Lemonjelly.KY|
|Come|Lemon Jelly|Lemonjelly.KY|
|Elements|Lemon Jelly|Lost Horizons|
|Space Walk|Lemon Jelly|Lost Horizons|
|Ramblin’ Man|Lemon Jelly|Lost Horizons|
|Return to Patagonia|Lemon Jelly|Lost Horizons|
|Nice Weather for Ducks|Lemon Jelly|Lost Horizons|
|Experiment Number Six|Lemon Jelly|Lost Horizons|
|Closer|Lemon Jelly|Lost Horizons|
|The Curse of Ka’zar|Lemon Jelly|Lost Horizons|
|So Easy|Rv?yksopp|Melody A.M.|
|Eple|Rv?yksopp|Melody A.M.|
|Sparks|Rv?yksopp|Melody A.M.|
|In Space|Rv?yksopp|Melody A.M.|
|Poor Leno|Rv?yksopp|Melody A.M.|
|A Higher Place|Rv?yksopp|Melody A.M.|
|Rv?yksopp’s Night Out|Rv?yksopp|Melody A.M.|
|Remind Me|Rv?yksopp|Melody A.M.|
|She’s So|Rv?yksopp|Melody A.M.|
|40 Years BackCome|Rv?yksopp|Melody A.M.|
|Remind Me|Rv?yksopp|Melody AM|
|Femme d’Argent|Air|Moon Safari|
|Zdarlight (Voyage Mix)|Digitalism|My House Is Your House, Vol. 1 Disc 1|
|First Breath After Coma|Explosions in the Sky|The Earth Is Not a Cold Dead Place|
|The Only Moment We Were Alone|Explosions in the Sky|The Earth Is Not a Cold Dead Place|
|Six Days at the Bottom of the Ocean|Explosions in the Sky|The Earth Is Not a Cold Dead Place|
|Memorial|Explosions in the Sky|The Earth Is Not a Cold Dead Place|
|Your Hand in Mine|Explosions in the Sky|The Earth Is Not a Cold Dead Place|
|Intro|Carbon Based Lifeforms|The Path|
|Behind the corner|Carbon Based Lifeforms|The Path|
|Rain|Carbon Based Lifeforms|The Path|
|Rise to tomorrow|Carbon Based Lifeforms|The Path|
|Hold|Carbon Based Lifeforms|The Path|
|Machinery|Carbon Based Lifeforms|The Path|
|And contact|Carbon Based Lifeforms|The Path|
|Sinful things|Carbon Based Lifeforms|The Path|
|Dreamshore forest|Carbon Based Lifeforms|The Path|
|Submerged|Carbon Based Lifeforms|The Path|
|Contaminated area|Carbon Based Lifeforms|The Path|
|Last breath|Carbon Based Lifeforms|The Path|
|Station blue|Carbon Based Lifeforms|The Path|
|Or plan B|Carbon Based Lifeforms|The Path|
|Eple (Black Strobe Remix)|Royksopp|The Remix Album|
|Remind Me (James Zabiela Eighties Ingeborg Mix)|Royksopp|The Remix Album|
|Poor Leno (Silicon Souls Dub Remix)|Royksopp|The Remix Album|
|49 Percent (Angello & Ingrosso Remix)|Royksopp|The Remix Album|
|What Else Is There (Vitalic Remix)|Royksopp|The Remix Album|
|Sparks (Murk Downtown Miami Remix)|Royksopp|The Remix Album|
|So Easy (So B.H.Q. Remix By Derrick Carter)|Royksopp|The Remix Album|
|Remind Me (Someone Else’s Radio Remix)|Royksopp|The Remix Album|
|Only This Moment (Alan Braxe And Fred Falke Remix)|Royksopp|The Remix Album|
|49 Percent (Mandy Remix)|Royksopp|The Remix Album|
|Eple (Fatboy Slim Mix)|Royksopp|The Remix Album|
|Poor Leno (Sander Kleinenberg Mix)|Royksopp|The Remix Album|
|Remind Me (Ernest Saint Laurent Moonfish Mix)|Royksopp|The Remix Album|
|What Else Is There (Jacques Lu Cont Radio Mix)|Royksopp|The Remix Album|
|What Else Is There (Thin White Duke Mix)|Royksopp|The Remix Album|
|Beautiful Day Without You (Rex The Dog Remix)|Royksopp|The Remix Album|
|Day One|Explosions in the Sky|The Rescue|
|Day Two|Explosions in the Sky|The Rescue|
|Day Three|Explosions in the Sky|The Rescue|
|Day Four|Explosions in the Sky|The Rescue|
|Day Five|Explosions In the Sky|The Rescue|
|Day Six|Explosions In the Sky|The Rescue|
|Day Seven|Explosions In the Sky|The Rescue|
|Day Eight|Explosions In the Sky|The Rescue|
|Abiogenesis|Carbon Based Lifeforms|World of Sleepers|
|Vortex|Carbon Based Lifeforms|World of Sleepers|
|Autumn in Ganymede|NULL|Cowboy Bebop|
|Blues Sax|NULL|Cowboy Bebop|
|Go Go Cactus Man (Whistling Song)|NULL|Cowboy Bebop|
|Tank! (Luke Vibert Remix)|NULL|Cowboy Bebop|

Mounting ISO Images in Mac OS X Without Expensive Software

I was speaking with a colleague today about ISO files/images in Mac OS X, and when he expressed his disappointment with existing software.
I said I would show him some cheap and easy ways to mount ISO files and how to backup any CDROM using Disk Utility.

Mounting an ISO on your Mac is accomplished using the hdiutil command.
To attach an image file,

  1. you will first need to open up your
  2.  type  hdiutil attach -readonly filename where filename is the full unix path of your file (just to be safe). When I was testing this my command looked like “hdiutil attach -readonly /Users/ck/Downloads/cdrom-1.33.iso”.
  3. If you run into problems or find your image type says not supported, generally because it is a .cdr file, try hdiutil attach -imagekey diskimage-class=CRawDiskImage filename.

This should mount the image in your Finder sidebar as you would expect a normal CDROM would. If we are concerned with creating images with Disk Utility, that is as simple as dragging the inserted CD onto the Disk Utility application, or selecting it within Disk Utility and selecting New Image.

Looking for the Excel 2008 Analysis Toolpak for Mac?

I also spent a good twenty minutes looking for the Excel 2008 Toolpak addon which Microsoft advertises in their knowledge base, unfortunately this link is broken and there is no place to download and install said addon.

Do not despair! The functionality you seek is actually included in Excel, you just need to go looking for it. If you check your formula bar/builder, you will find that the statistical tools you crave(like the nice correlation tool) are right there.


MySQL Gem and Rails 3.0beta4 issues

If you are running OS 10.6 (Snow Leopard) and you are having problems installing the mysql gem via bundler, there may be a simple fix.

While fooling around with bundler/macports, I was having an issue where bundler would throw an exception:

ERROR:  Error installing mysql:
ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb
extconf.rb:10: command not found: /opt/local/bin/mysql_config5 –cflags
ERROR:  Error installing mysql:        ERROR: Failed to build gem native extension.
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rbextconf.rb:10: command not found: /opt/local/bin/mysql_config5 –cflags

It took me a good 5 minutes of tracking down the problem to find out that /opt/local/bin/mysql_config5 was a symlink to /opt/local/lib/mysql5/bin/mysql_config, and that for some reason, while the file was there and filled with delicious code, it wasn’t executable.
One sudo chmod +x later, the mysql gem installs like a charm.