SQL Azure available PowerShell Cmdlets…

Here’s some links you check on available cmdlets for SQL Azure:

Windows Azure Service Management CmdLets: http://code.msdn.microsoft.com/azurecmdlets

Exercise 2: Using PowerShell to Manage Windows Azure Applications: http://msdn.microsoft.com/en-us/wazplatformtrainingcourse_deployingapplicationsinwindowsazurevs2010_topic3.aspx

This something to keep in mind.  Azure is here to stay!

SQL Denali missing “IF Exist…", default option is “False”…

On my previous blog, I mention about the missing “IF EXIST …” SQL Statement when scripting out a Drop/Create a table.

image

I should have known that there’s an option you can change this behavior.  On SSMS Denali, look under “Tools | Options | SQL Server Object Explorers | Scripting”, and under “Object Scripting Options” you will find the “Include IF NO EXIST Clause”.  Yes, you read it right!!  People have complain about the wording of this option.  Why not use “Include IF EXIST clause” or “Enable/Disable IF EXIST Clause”?   Well, as they say in Survivor…  It’s time to vote!

I found this Microsoft Connect feedback: http://connect.microsoft.com/SQLServer/feedback/details/624075/include-if-not-exists-clause-impacts-drop-scripting

Look like Microsoft is listening and they have a fix for the next release of Denali.  Good Job Microsoft! 

Creating Multi-Dimension Arrays with PSObjects

While working on my book, on my chapter about working with objects, I went through a series of examples on using PSObject and Hash Tables which made me realized that creating NoteProperties is a thing of the past.  Thanks to the “-Property” parameter whe using the New-Object which allows you to use your Hash Table content and build your object Property member type.

New-Object PSObject –Property [HashTable]

Take a look at this previous blog post by the PowerShell Team: http://blogs.msdn.com/b/powershell/archive/2009/12/05/new-object-psobject-property-hashtable.aspx

So, while answering the forum post about “NoteProperties on an ArrayList”, I found myself creating a Multi-Dimension Array on a PSObject.    In my example, I’m trying the create two different Hash Tables, $o1 and $o2, containing the same property with some values.  Then, I’m adding them to the my $a1 PSObject variable using the “+=” operator and this have allow me to create a Multi-Dimension array.

Here’s the code:

## Creating multi-dimension array

[Array] $a1 = $null

$o1= @{ Num = “12”,”34″}

$a1 = new-object PSObject -Property $o1

foreach($i in $a) { $i.num }

$o2 = @{Num = “2”,”4″}

$a1 += new-object PSObject -Property $o2

$a1

foreach($i in $a1) { $i.num }

# Display one of the Dimension Element:
$a1[1].num[1]      # will return value = 4

$a1[0].num[1]      # will return value = 34

Here’s the image with the results:

image

Now, let’s take a look at the $a1 list of member types using Get-Member:

image

Yes, although we use the “-Property” in the New-Object, it will create the NoteProperty for you. 

So would you rather code using Add-Member:

Add-Member -InputObject $o1 -Type NoteProperty -Name Num -Value 12

Or, use the Hash Table concept:

$o1= @{ Num = “12”,”34″}

Well, just let your imagination go!!