SQLvariations: SQL Server, a little PowerShell, maybe some Hyper-V Rotating Header Image

Uncategorized

And We’re Back!

This page has been intentionally left blank for most of the last 4 months while I get some higher priority items taken care of. The hole in my theory about taking a break from blogging and being on twitter was that hundreds of people still have questions about PowerShell and my email address. I plan to post the answers to those questions over the next several weeks.

In the meantime I want to give a quick mention about SQL Saturday #89 happening here in Atlanta in just 12 days. We’ve hit the maximum number of registrations we feel comfortable handling. If you’re on the wait list, we’ll send out an email later this week to people that were able to successfully register but now can’t make it, asking them to unregister. From the looks of the registration counts this might end up being a little under twice the size of last year’s SQL Saturday.

More blogs coming soon!

Getting Priorities Done



Getting Priorities Done

Last year I kept hearing about all these people using something called GTD (Getting Things Done).  They didn’t talk about it much.  But occasionally one of them would send out an excited tweet mentioning GTD.  I got tired of hearing all these excited tweets and finally decided to dive in.  I had actually purchased the audiobook of GTD years ago but never got around to listening to it.  I was only a few pages into the book when I had the urge to make a big list of everything I have to finish.  I started out putting everything into a spreadsheet.  Everything from “Script new Mount Point Daily Check Job” to “Remember to pickup dry cleaning” was going into this list.  I would frequently realize that I was behind on a certain task; so I’d stop and take care of that item. 

After 6 hours I was in love with this technique.  After 18 hours I was slightly overwhelmed.  And after  48 hours I was ready to quit.  I had a list of over 80 items, and adding to that list did help me finish any of those items.  In fact the list left me feeling that life was more out of control than before my to-do items were written on paper.  I couldn’t understand how anyone –let alone all these people I had heard of – could get anything done using method.  Like my first attempts with PowerShell, I closed it down and decided it wasn’t very useful.

At the same time I had just started a new job much closer to home.  I had an extra hour available for every workday, but I was accomplishing less than ever.  It felt weird.  Almost everything was in place – so much so that I felt anyone should be able to succeed given these conditions – and yet I wasn’t!  I wasn’t getting to the gym more, I wasn’t spending significantly more time with my daughter and I wasn’t all that much less stressed.

I took a while, but after seeing that list and realizing how much was there I recognized that, short of having two clones, I was never going to be done with my to-do list.  What to do?  Simple.  That list must be shorter. With the writing on the wall I decided to categorize the things on my now out of date GTD list and see what I could scrap.  To say it was a punch in the face would like saying Southerners like Barbeque.  “It ain’t dinner unless a pig had to die.”  Right now my daughter is 13 and still listens to me at least pretends to listen when I speak.  I’m not sure how much longer that will last.  Her school is 2.2 miles away from both our home and my office  (For those playing at home, that is a 12 minute Atlanta commute. :-) ). At the end of the day life is about priorities and I’ve finally figured mine out. So until my daughter stops letting me drop her off at school, play taxi-cab for her and her friends, and generally allows me to be seen with her in public… well, I’m not going to have a lot of free time to do much else :-)

So what does that mean?  Am I going to stop blogging, writing, speaking, everything?  I don’t know, quite possibly.  Maybe for a while, maybe for a good while.  I have two items in my Professional Development category that I’ve committed to get done (and thankfully they both won’t take up very much time at all).   I’m still going to finish those two and they might result in some interesting content.  But for everything else?  Well following the GTD method those are all marked as “Maybe-Some Day”.

MEME Monday: Taking a Break

Taking a break to spend more time with my daughter Dorothy.

– Thanks for the idea Tom

Atlanta User Groups Different December 2010 Dates

For the month of December the meeting dates and what happening for different User Groups has been all rearranged for obvious reason (Christmas vacation).  Here is what’s going on at the three user groups that I attend regularly:


Atlanta B/I: Tonight!
Atlanta MDF: Holiday Party, Next Wednesday
This is a joint party with the following user groups:
AtlantaMDF, Atlanta MS Pros, Atlanta .NET, Atlanta PHP, AWDG, Gwinnett .Net, IASA Atlanta, Silverlight Atlanta 
Atlanta PowerShell: No meeting this month


Topic: BI: Then and Now?
Level: Beginner
Date: Monday, December 6, 2010
Location: Matrix Resources Dunwoody Office
Sponsor: Strategy Companion Corporation

Overview:
We will begin by taking a look how the focus and characteristics of Business Intelligence have changed over the last 25 years. We will also discuss the recent history of Microsoft’s focus on BI, and will take an in-depth look at another approach to SQL Server-based BI provided by Strategy Companion Corporation. You will see why companies such as Citigroup, L’Oreal, Honeywell, DataQuick, and many others have embraced Analyzer, Strategy Companion’s award-winning front-end to Analysis Services, for their Business Intelligence applications. You’ll see why SQL Server magazine recently called Analyzer "the best solution to complete the Microsoft BI platform." (Editor’s Best Award, December 2009.) And you’ll learn ways to quickly and add significant value to your SQL Server-based data – the kind of value business people will be able to see, understand, and appreciate.

Speaker: Bob Abernethy
Bob Abernethy is SVP & GM of Strategy Companion Corporation. A veteran of Oracle Corporation and Siebel Systems, Bob brings over twenty years of software industry experience to his discussion with customers about their Business Intelligence implementations. Bob received his Bachelor of Science degree from Cornell University in New York and his Masters of Management Information Systems from West Coast University in Southern California. the current president of the Kansas City SQL Server Users Group.


Atlanta Technical Community Holiday Party

This year, Microsoft, will bring the Atlanta technical community together not only in spirit, but in holiday fun as well. We invite you to join us for a holiday celebration at {three} Sheets on Wednesday, December 15 at 7pm.

This will be the perfect event for networking and seeing what’s going on with the different technologies in the community. When you’re not mingling, have some fun playing the new Xbox Kinect. Or enjoy some of the delicious appetizers provided by Microsoft.

Don’t forget, it’s the giving season! It’s not required, but please bring an new, unwrapped toy to give to Toys for Tots. We would like to do our part for this wonderful cause.

Finding SQL Servers with PowerShell

image Have you ever clicked a drop-down to connect to one of your databases and noticed an instance that you don’t remember setting up? Or maybe a server that was recently setup for some new application in your organization, that no one mentioned it needing SQL, but you come back from your day off and notice that server is now one of your available SQL Servers? If your office is like mine those things happen all too often.

There are several different methods to finding out just how many SQL Servers are running on your “network” right now. Each method has pros and cons. But the biggest problem that I run into is: ‘what is defined as the network?’ Is it just the network of computers at your office? Does it include servers at your collocation facility? What if you have a completely separate domain for Development?

The first method I’m going to point out to you is really easy to use but it’s results vary depending on your network rights and where you run it from, but, it still can find machines that you didn’t even know about so lets have a look. Wait, why would I start out with an example that’s so imperfect? Because this method uses the same .Net components that are used to generate the list of servers you see when you click on the “<Browse for more>” option in the drop down of the SSMS connection window*. This means that you’ll see a list that you recognize (probably). Fire up the ISE and kick off this command:

[System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources()

Now if you’re just on you laptop or sitting at home or something you’ll probably get a nice short list like this: image But if you’re at work, you’ll get back a much longer list; maybe even longer than you expected :-)

Heck how many servers just came back anyways! The answer to that question is really easy, just pipe the output of the command to Measure-Object and find out like this:

[System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources() | Measure-Object

and you’ll get some output like this:

image Now like I said earlier, these results are going to vary depending on where you run the command so here’s what I recommend. Run this command from your desk. Then try it from a machine that is on a different network segment that you’re usually on – like a Dev domain. Then go home, VPN in and run the command, see how many you get back now.

OK that’s great but with all of these variances can I do anything useful with this example? Sure you can. Take your results and put them in a table. First build a simple table to use:

CREATE TABLE FoundSQLServers (
ServerName VARCHAR(128),
InstanceName VARCHAR(128),
IsClustered VARCHAR(3),
VersionNumber VARCHAR(64)
)

Then build some insert statements off of the results like this:

$SQL = [System.Data.Sql.SqlDataSourceEnumerator]::Instance.GetDataSources() | `
foreach {
"INSERT INTO dbo.FoundSQLServers VALUES ('$($_.ServerName)', '$($_.InstanceName)', '$($_.IsClustered)', '$($_.Version)')" `
>> C:\Temp\INSERTFoundSQLServers.sql
        }

To open up the file that was just created in Management Studio just run this

Ssms.exe C:\Temp\INSERTFoundSQLServers.sql

…and you should get some nice insert statements for that table like this:

INSERT INTO dbo.FoundSQLServers VALUES ('WIN7ULT', 'KILIMANJARO', 'No', '10.50.1600.1')

Go ahead and insert those rows into your table, maybe even give the table a little bit different name like: FoundSQLsFromVPN or FoundSQLsFromDev. Run some queries to compare the results you get from different network segments; see which servers we found both at home (through VPN) and at work from your desk; and more importantly which ones are only found from one of those locations. We’ll take a look at a couple of different methods I’ve learned about in future posts but I wanted to get you started with finding out how well this method finds your servers and knowing how your network location can affect it. Just in case you’ve recently started a new job or something ;-)

Special Thanks: I just wanted to take a moment to thank Grant Fritchey ( blog | twitter ) for doing a tech-check on this post and helping convey my points a little more concisely.

* Small Disclaimer: I was told that it’s the same .Net component used by applications like SSMS but since I don’t work at Microsoft and I’m not a developer I wouldn’t even know where to start to verify this but the list produced has always been very similar or down-right identical.

24 Hours of PASS: Summit Preview and Me?

I *Might* be speaking at the 24 Hours of PASS: Summit Preview event.  I say “Might” because I’m speaker #25, the first Alternate.  The lineup is pretty freaking awesome so I hope that no one cancels but if they do I’ve got some fresh PowerShell for SQL Server content to show everyone.  I’ll also be moderating questions for Kalen Delaney’s session on Locking tomorrow at 3pm EDT.  Make sure you pick up a case of Red Bull one your way to work because you’re not going to want to miss a minute of this FREE TRAINING.

Also, this time the event has been super-sized with 4 additional Microsoft sessions so if you already signed up and you didn’t know that, check them out; they do require additional registration.   And yes, technically that makes me speaker #29 so let’s just go ahead and change that to speaker #1A :-)

24 Hours of PASS: Summit PreviewSeptember 15, 2010
Session 01  (DBA) – Start time 12:00 GMT on September 15
I Am a DBA – Why Should I Care About SQL Server 2008 R2?
Presenter: Peter Ward
Attend Meeting Now
Session 02 (DBA) – Start time 13:00 GMT on September 15
Gather SQL Server Performance Data with PowerShell
Presenter: Allen White
Attend Meeting Now
Session 03 (BI) – Start time 14:00 GMT on September 15
Why Data Warehousing Projects Fail (And What You Can Do About It)
Presenter: Craig Utley
Attend Meeting Now
Session 04 (DBA) – Start time 15:00 GMT on September 15
Hardware 201: Selecting and Sizing Database Hardware for OLTP Performance
Presenter: Glenn Berry
Attend Meeting Now
Session 05 (PD) – Start time 16:00 GMT on September 15
Managing Teams
Presenter: Andy Leonard
Attend Meeting Now
Session 06 (DBA) – Start time 17:00 GMT on September 15
Enforcing Compliance with Policy-Based Management
Presenter: Ken Simmons
Attend Meeting Now
Session 07 (BI) – Start time 18:00 GMT on September 15
Intro to MDX
Presenter: Stacia Misner
Attend Meeting Now
Session 08 (Dev) – Start time 19:00 GMT on September 15
Isolation vs Concurrency: What Are the Choices?
Presenter: Kalen Delaney
Attend Meeting Now
Session 09 (DBA) – Start time 20:00 GMT on September 15
Identifying Costly Queries
Presenter: Grant Fritchey
Attend Meeting Now
Session 10 (PD) – Start time 21:00 GMT on September 15
How to Rock Your Presentations
Presenter: Douglas McDowell
Attend Meeting Now
Session 11 (Dev) – Start time 22:00 GMT on September 15
eXtreame Database Design
Presenter: Paul Nielsen
Attend Meeting Now
Session 12 (BI) – Start time 23:00 GMT on September 15
Delivering KPIs with Analysis Services
Presenter: Peter Myers
Attend Meeting NowMicrosoft Bonus Session – Start time 00:00 GMT on September 16
Peer-to-Peer Transactional Replication
Presenter: Jean-Yves Devant
Attend Meeting Now

Microsoft Bonus Session – Start time 01:00 on September 16
TempDB Configuration and Management
Presenter: Dipti Sangani
Attend Meeting Now

September 16, 2010


Session 13 (BI) – Start time 12:00 GMT on September 16
Upgrading DTS Packages to SSIS
Presenter: Brian Knight
Attend Meeting Now
Session 14 (DBA): Start time 13:00 GMT on September 16
Statistics: How to Prove Everything but the Truth
Presenter: Kevin Goode
Attend Meeting Now
Session 15 (BI) – Start time 14:00 GMT on September 16
SQLBI Methodology
Presenters: Alberto Ferrari and Marco Russo
Attend Meeting Now
Session 16 (PD) – Start time 15:00 GMT on September 16
Preparing for Your Next Job
Presenter: Chris Shaw
Attend Meeting Now
Session 17 (DBA) – Start time 16:00 GMT on September 16
Storage for the DBA
Presenter: Denny Cherry
Attend Meeting Now
Session 18 (DBA) – Start time 17:00 GMT on September 16
SQL Server 2008 R2 StreamInsight
Presenter: Klaus Aschenbrenner
Attend Meeting Now
Session 19 (Dev) – Start time 18:00 GMT on September 16
T-SQL Brush-Up: The Best Things You Forgot You Knew
Presenter: Jen McCown
Attend Meeting Now
Session 20 (DBA) – Start time 19:00 GMT on September 16
Automate Your Database Maintenance
Presenter: Brad McGehee
Attend Meeting Now
Session 21 (Dev) – Start time 20:00 GMT on September 16
Relational Database Design for Utter Newbies
Presenter: Kevin Kline
Attend Meeting Now
Session 22 (BI) – Start time 21:00 GMT on September 16
Zero to Cube: Fast Track to Analysis Services Development
Presenter: Adam Jorgensen
Attend Meeting Now
Session 23 (Dev) – Start time 22:00 GMT on September 16
Top 10 Design Mistakes
Presenter: Louis Davidson
Attend Meeting Now
Session 24 (Dev) – Start time 23:00 GMT on September 16
Understanding SARGability
Presenter: Rob Farley
Attend Meeting Now

Microsoft Bonus Session – Start time 00:00 GMT on September 17
SQL Server R2 Utility
Presenter: Eddie Fong
Attend Meeting Now

Microsoft Bonus Session – Start time 01:00 GMT on September 17
SQL Server Security Tips & Tricks
Presenter: Li-Sung Lee, Microsoft
Attend Meeting Now

http://www.sqlpass.org/24hours/Fall2010

SQL Saturday Nashville Code and Slides

Wow.  I think Nashville may have just thrown down the gauntlet and tried to steal the title from Atlanta for ‘Best Attendee Shirt’.  It’s pretty sweet and I can’t wait to wear mine.  The speaker shirt was excellent as well; I may wear mine to work next Friday.  Unfortunately I couldn’t stick around because I had a date with history but as promised, here are the scripts and slides I used.

As for the session itself.  I got several compliments and saw quite a few good tweets on twitter but I have to say I could have done better.  *As always* I tried showing off a script that I had never dived into during a SQL event and it ended up generating more questions than I expected.  It was a little out of sequence with my normal routine (hey you have to try new things) and unfortunately I realized afterwards that it should have been the 4th script that I demoed not the second.  BUT.  The questions that were asked were great and it was great feedback as to what people were able to pick up on without ever having seen PowerShell before.

I will reseed this scripts for my presentation tonight at the Columbus, GA chapter.  Who know, maybe if I get it right Louis will let me come back and do the full session after the Summit.  :-)

Get-Sales | Out-Map = T-SQL Tuesday #005 – Reporting

For this month’s T-SQL Tuesday I thought I’d go with something useful that I’ve been meaning to blog about for weeks now.  While listening to the PowerScripting Podcast a few month’s back I heard about a product that sounded really cool for simple data visualization and quickly showing people just how powerful PowerShell is.  Now to get this to work using all the code on the screen you’ll at least have to download the trial version of of the Power Gadgets however even without the method I describe is important if you’re new to this type of reporting (desktop gadgets).

Turns out this little piece of software had even more packed into it than I was hoping for.  I needed a piece of software that could allow me to pipe data to it to display it in a desktop gadget as a list.

Before I show you how to setup this quick-and-easy tool to create desktop gadgets I want to issue a warning against setting up this type of thing directly against your production database; read all the way through or don’t blame me when you bring your production environment down.

image

What you want to do (at the very least) is to have all of the gadgets that you deploy read from a central location where they only have to scoop up the results of the query that you’re trying to report on, and not 400 gadgets running the query itself.  An easy way to accomplish this would be to run the query in an Agent Job against your production environment (assuming that you don’t have a live reporting copy) and deposit those results in a table.  Let’s see if we can step through an example with the AdventureWorks database.

If this below were your query to show your sales for today…

SELECT SUM(SOD.OrderQty) AS OrderQty, s.StateProvinceCode
  FROM Sales.SalesOrderHeader SOH
 INNER JOIN Sales.SalesOrderDetail SOD
    ON SOH.SalesOrderID = SOD.SalesOrderID
  JOIN Production.Product P
    ON SOD.ProductID = P.ProductID
  JOIN Person.Address A
    ON SOH.BillToAddressID = A.AddressID
  JOIN Person.StateProvince S
    ON A.StateProvinceID = S.StateProvinceID
 WHERE SOH.OrderDate = ’2001-07-01 00:00:00.000′ –<—This would get GETDATE() or something
 GROUP BY S.StateProvinceCode

…you would really want to create an Agent Job to load that into a table and select off of the table.  For simplicity we’ll leave out the job and just use the queries.

/* <Do this part only one time>*/

USE [AdventureWorks]

GO

CREATE SCHEMA [Report] AUTHORIZATION [dbo]

GO

CREATE TABLE [Report].[TodaysSalesOrderByState](

[OrderQty] [int] NULL,

[StateProvinceCode] [nchar](3) NOT NULL,

[LastLoadTime] DATETIME NOT NULL CONSTRAINT [DF_LastLoadTime] DEFAULT GETDATE()

) ON [PRIMARY]

/* </Do this part only one time>*/

Then this…

/* <This is the part that would eventually go into an agent job, along with a delete statement before it that was in the same transaction>*/

 INSERT INTO Report.TodaysSalesOrderByState (

[OrderQty],

[StateProvinceCode])

SELECT SUM(SOD.OrderQty) AS OrderQty, s.StateProvinceCode

  FROM Sales.SalesOrderHeader SOH

 INNER JOIN Sales.SalesOrderDetail SOD

    ON SOH.SalesOrderID = SOD.SalesOrderID

  JOIN Production.Product P

    ON SOD.ProductID = P.ProductID

  JOIN Person.Address A

    ON SOH.BillToAddressID = A.AddressID

  JOIN Person.StateProvince S

    ON A.StateProvinceID = S.StateProvinceID

 WHERE SOH.OrderDate = ’2001-07-01 00:00:00.000′ –<—This would get GETDATE() or something

 GROUP BY S.StateProvinceCode

/* </This is the part that would eventually go into an agent job>*/

Now you’ll want to create a stored proc that will be used to call the report data.  It will also make creating the report nice and clean.

CREATE PROCEDURE [dbo].[rp_MapThat]
AS 

SELECT [OrderQty]
      ,[StateProvinceCode] AS ‘State’
  FROM [AdventureWorks].[Report].[TodaysSalesOrderByState]
GO

After that all you have to do is to go ahead and create the gadget using this little script:

#Go ahead and add the SQL Snapins
add-pssnapin SqlServerCmdletSnapin100
add-pssnapin SqlServerProviderSnapin100
#add the Gadgets Snapin
add-pssnapin PowerGadgets            

invoke-sqlcmd -query "EXEC dbo.rp_MapThat" -database AdventureWorks -serverinstance WIN7\KILIMANJARO | out-map -values OrderQty -label State -title "CountByState" -refresh 0:1:0

 

And now you’ve got a gadget prototype.  I’m sure you can figure out how to turn it into an operational gadget for your company.

 

 

LiveJournal Tags: