Category Code

The PowerShell of the Future

PowerShell Today

Allen White recently presented for CBusPASS about PowerShell. First off, I’d like to say thanks to Allen for driving down from Canton, OH to speak in person. He took the time to stick around afterwards and chat about a bunch of things that were on user group members’ minds.

Allen’s presentation covered the basics of PowerShell through concrete examples – automating backups, restores, and database creation. Throughout the entire process, Allen demonstrated many aspects of PowerShell that make the DBA’s life easier. Allen demonstrated how it’s possible to easily work with data from files, the registry, and SQL Server simultaneously through PowerShell. Many of these things would take a considerable amount of work with T-SQL, if they’re even possible at all.

Interestingly, one of the first things I was reminded of was how much PowerShell looks like a variety of programming languages, specifically Perl. One of the nicest aspects of Perl is that it’s a glue language. Glue languages help you piece together various pieces and parts of your servers that have no real way to communicate with each other. PowerShell makes it possible to do the same thing, natively, on Windows.

PowerShell, as part of the Common Engineering Criteria, is enabled in all of the newer Microsoft server products. So, you can be sure that PowerShell is available as part of SQL Server, Exchange Server, Windows Server 2008, SharePoint, and many other products that I’ve forgotten. This will make it easier to take care of a larger number of servers and diverse server products using a single language.

This is the state of PowerShell right now. PowerShell 2.0 is available with Windows 7 and Windows Server 2008 R2.

What’s really exciting is PaSH.

PowerShell Tomorrow

Object reference not set to an instance of a phone

Object reference not set to an instance of a phone

PaSH is an open source reimplementation of PowerShell for other operating systems – Linux, OS X, Windows Mobile.

Think about that for a minute… Did you really wait for 60 seconds to think about that? Good.

With PaSH I could VPN to my network, fire up my PowerShell prompt on my phone, and start diagnosing server problems. Or run a remote backup. Or failover a cluster. Or any number of wonderful and amazing things.

Here’s where it gets cooler: If PaSH catches on, we could soon see similar libraries for MySQL or Apache. Maybe someone will even write a layer that maps common Windows and SQL Server functionality to their open source equivalents. A heterogenous datacenter becomes a lot easier to manage when you can write maintenance scripts using a common language across all platforms.

Looking forward, this isn’t so far fetched. The open source community has embraced mono, the open source version of the .NET Framework – I have mono and MonoDevelop (the mono IDE) installed on my mac. It’s included in several Linux distributions by default. It isn’t that much of a stretch to imagine PaSH becoming an effective and accepted cross-platform administrative scripting language.

Links for the Week 2009.11.20

Bonus link dump week! Since I haven’t done one of these in several weeks, some of these links go all the way back to October 29th, enjoy.

SQL Server

Development

Stuff & Things

GUIDs: Not Necessarily Unique

So, you though that GUIDs were supposed to be unique, eh? You aren’t alone. A lot of people assume that GUIDs are unique. Hell, unique is in the name!

On Friday, I had a bug report filed about a UNIQUE constraint violation. Seeing as how I had bigger fish to fry, and this functionality is only rarely used, I put it aside until this morning when I took a closer look at the bug report and the code in question.

The table in question looks something like this:

CREATE TABLE dbo.Widget
(
  WidgetId BIGINT IDENTITY(1,1) NOT NULL,
  -- other columns
  LegacyIdentifier VARCHAR(50) NOT NULL
);

Before I get yelled at for a VARCHAR(50) in my database let me assure that this is actually a 50 character random garbage string from our legacy COBOl application. Nobody got lazy and just made a VARCHAR(50)… this time.

LegacyIdentifier has a unique constraint on it because all of the Widgets need to be unique between the new system and the old system. In order to keep this uniqueness going I thought to myself, “I know, the U in GUID stands for Unique, I’ll use that since I’m not clustering on it.” I wrote a little piece of code that puts “New_” at the beginning of a GUID and then uses that string as the LegacyIdentifier. That was about 11 months ago. On Friday, we received an exception warning that the application had attempted to insert a duplicate value into the LegacyIdentifier column.

What now? Well, I’m not sure. I’m going to implement functionality to force the database to keep generating GUIDs and attempting inserts until it actually generates a unique GUID.

This solution doesn’t make me happy, though, because GUIDs are not unique. A GUID is, in theory, unique. There are, after all, 2^128 possible permutations, so the probability of the same GUID being generated twice are incredibly slim. However, it can happen. (SQL Server uses a V4 GUID algorithm, which is a pseudo-random number and, as such, is not truly random. Newer GUID algorithms use an SHA hash for randomness, but how random is random?)

What are we to do when we need a truly unique identifier? Frankly, I’m not sure. The thought crossed my mind of generating a random number and casting it to VARCHAR and appending it to the GUID. The statistical likelihood of generating two random values that are the same as a prior value is so astronomically low that I should probably buy lottery tickets if there is ever a collision. As it stands right now, I’ve opted to retry the insert until it actually succeeds (or for 5 times, after which the user is doomed).

So, there you have it, GUIDs are not guaranteed to be unique and you should plan accordingly.

Links for the Week of 2009.10.30

These are a day late. Sorry about that. It’s been one helluva week.

Also, November 1st marks the beginning of National Novel Writing Month. So, if you’ve had a story inside you waiting to get out, wait no further!

SQL Server

Development

Stuff & Things

Links for the Week of 2009.10.23

I came across a lot of great links in the last week. So many that I had to cut about 40% of them to make this list.

As always, you can check out the firehose at my delicious bookmarks page.

SQL Server

Development

Stuff & Things

Links for the Week of 2009.10.09

SQL Server

Why I prefer surrogate keys instead of natural keys in database design Mladen Prajdic put together a great article about using surrogate keys in database design. The best part is that a lot of bright people sounded off in the comments.

Donald Farmer Discusses the Benefits of Managed Self-Service BI I spoke with Donald Farmer about this topic when I was at the Richmond Code Camp last weekend. This is an incredible topic that has a lot of promise for the future of Business Intelligence.

Development

Mastering CSS Coding: Getting Started CSS is difficult to master. Very difficult to master. However, once you understand how CSS works it is a very powerful tool.

Multiple View Engines with MVC Turbine One of the coolest things about ASP.NET MVC is the flexibility it brings to ASP.NET web development. Javier Lozano demonstrates how it is possible to use multiple view engines within the same page.

Stuff & Things

9 Ways to Make Your Writing More Compelling 9 great tips for dramatically improving your writing.

Freelance Contracts: Dos and Don’ts If you’re looking to freelance, it’s important to make sure that your contracts are in order. This can cause no end of pain, trouble, and difficulty if your contracts are ambiguous. Smashing Magazine has some great information to make sure your contracts are in good working order.

Cyanide & Happiness

Links for the week – 2009.10.02

SQL Server

Developers, use Profiler to profile yourself John Sterrett goes over how to use profiler to profile your own SSMS session.

Toys and Tools Mike Hillwig put together a list of great SQL Server tools.

The ABCs of Management Studio Shortcuts Glory be to keyboard shortcuts

Development

ASP.NET MVC 2 Preview 2 New MVC hotness has been released. Yes, it’s a preview, but this contains some interesting features. Better get it while the getting is good!

Stuff & Things

Google Search Options Offer More Recent, Personal Results Ever get really frustrated searching for something that you saw online? Ever know that the blog you’re looking for was written a week ago? Google’s new search options will let you narrow down your search with some particularly specific criteria.

Why Good Writing Matters – And How You Can Improve Good writing is incredibly important. There’s a reason why I spent four years of my life studying writing: I knew that learning how to communicate effectively was important and that I could learn most skills (apart from rocket surgery) on the job.

29 ways to ingrain a behavior Forming habits is difficult. Especially when you’re trying to build new habits and get rid of old ones. 29 tips to help you change.

Links for the Week – 2009.09.25

SQL Server

There’s a three part series (one two three) on migrating databases. I’m sure many people have been through this before. I know I have. About a week before these three posts were published.

Ever wonder when you should use a filtered index and when you should use an indexed view? Yeah, I have too. The distinction hasn’t been all that clear (to me). Andrew Fryer clears that up a bit in this blog post.

Development

I like the idea of continuous integration. I like testing. I like automating everything until I don’t even have to think about it anymore. It can be done even with the database. Jeffrey Palermo and Eric Hexter demonstrated just how to get CI working with your database project using nothing but pure T-SQL.

Stuff & Things

These first two are for some RSS reader goodness. I haven’t gotten around to trying out Fever for my RSS feeds yet. The idea of paying $40 for an RSS reader is a bit steep. But, the idea of having my feeds add value to one another is intriguing. If you’re feeling a bit cheap, there’s always Helvetireader. This is a set of browser scripts and CSS that add a touch of class to your google reader.

The Personal MBA is a set of reading materials meant to teach everything that you would get in an MBA program. While I doubt that it’s the same as getting an MBA, I do like the idea of a reading list that’s designed to help me, a nerd, get better at something I suck at: business.

Soundtrack for a City Augmented reality – through our phones or sunglasses or our retinal implants – is only beginning. It’s new. Soon sight will be augmented by sound. I love this idea.

Links for the Week 2009.09.20

SQL Server

Distributed Queries – Remote Login Permissions and Execution Plans You can sometimes end up with SQL Server not generating good execution plans for remote queries. I just assumed that this was a problem with remote queries. Turns out that I was wrong and all you really need to do is give some specific permissions to the remote login. You learn something new every day.

John Paul Cook : Script to create all foreign keys Let’s make some foreign keys! How many times have you had to drop and recreate all of your foreign keys? I’ve had to do it, especially for complicated ETL processes where I really don’t feel like following the rules and I’d prefer to just throw data at a schema and validate it later. John Paul Cook has a great way to generate all of your keys as a drop and create. BOOM! DONE!

Development

Microsoft StreamInsight : Updated Sample Package StreamInsight is part of the new complex event processing framework that will be unleashed on the world in SQL Server 2008 R2. This mainly includes internationalization fixes and an updated help file.

Running Rake tasks in E-Text Editor e-text editor is a lot like TextMate, but for Windows. It’s a must if you’re doing any kind of Ruby development and don’t want NetBeans or Eclipse eating 95% of your system memory. I’ve run into problems using it to run my rake tasks in the past. My solution was to keep a terminal window open. Apparently there’s a better way.

Git Resources Git is what traditional source control wants to be when it grows up. I’m still learning and I have a long way to go on being 100% comfortable with git, however here’s a list of resources to help you along your route to using some sweet sweet version control.

Stuff & Things

Retro games are cool. I love retro gaming. In part because I don’t have a 3d accelerated graphics card in my macbook and my options are for retro games or flash games. The best part is that these aren’t abandonware games, these are legit games that have legally been released to the community. Go download some retro games. (The site is kind of slow because lifehacker linked to them, but be patient, it’s so worth it.)

i love typography has a link dump. I heart fonts. I heart link dumps. I super heart font link dumps.

Mistakes can be good. Matt at 37signals talks about the importance of revealing your mistakes and being honest about them and ties it in with an anecdote about Julia Child’s frank approach to her own cooking. I remember an episode of her show from when I was young where she tenderized meat with a 2×4. 20 years later I needed to tenderize meat, but I had no meat tenderizing hammer. But I did remember her advice about covering the meat and using anything available. So I covered the meat in saran wrap and then covered a book in saran wrap and I had a meat tenderizer. I’ve also used a shoe. True story.

Links for the Week of 2009.09.12

SQL Server

Optimizing Queries That Access Correlated datetime Columns DATE_CORRELATION_OPTIMIZATION is some good stuff. If you have an InvoiceDate column that happens to be close to the OrderDate column in a related table, and this setting is on, the compiler will generate what could be a much better optimization plan.

Difference between an index and a primary key Denny Cherry does a great job of explaining this one. I frequently misuse primary key and clustered index as the same in conversation (yes, I do have A LOT of conversations about databases, even outside of work). I need to be better about that. This reminds me why.

Development

Vertical Centering in CSS This question comes up every once in a while. I always forget how to do it. Hopefully this will help someone else get their vertical centering sorted out.

The Unspoken Truth About Managing Geeks I’m not a manager but I play one on TV. There some good info in here. Especially if you only play a manager on TV.

Using Accessibility Modifiers on Auto Properties Auto properties rule. Justin Etheredge demonstrates how to keep that level of awesome rolling forward.

Stuff & Things

Simplified Virtual PC Creation with Differencing Disks I don’t know what to say. The idea is so damn simple I don’t know why I didn’t think of it before. Thanks to Jonathan Kehayias for this article. This is going to save me so much time and trouble.

20 Tips for Writing for the Web

Flowing Data | Data Visualization and Statistics It’s a blog that’s devoted to different ways of presenting information. Gotta love that. Flat tabular display of data is good, but there’s often a better way. A much better way.

Make Fried Pie in Five Minutes and Kickstart Your Day Fried. Pie.

Monkey on a motorcycle

Think about the different areas of your life Love the quote.

This site is protected with Urban Giraffe's plugin 'HTML Purified' and Edward Z. Yang's Powered by HTML Purifier. 401 items have been purified.