SMO vs Invoke-Sqlcmd in Azure

Azure, PowerShell
I'm working on a series of Powershell scripts for the pre-conference seminars on Windows Azure SQL Database that I'm going to be giving at TechEd and the PASS Summit. One of the things I want to do is script out a full backup process (one that's consistent with transactions) which means I need to create a database copy. There's a nice neat T-SQL command that does this: CREATE DATABASE ADW_COPY AS COPY OF nmhdhskcew.AdventureWorks2012; So, being the lazy Powershell freak that I am, I figured I'd just pass it in with Invoke-sqlcmd as a single line like this: Invoke-Sqlcmd -ServerInstance $server -Database $db -Username $user -Password $password -Query $sql Which resulted in an unexpected error: Invoke-Sqlcmd : The CREATE DATABASE statement must be the only statement in the batch. Well, now I'm curious.…
Read More

A Little Azure Fun on Friday

Azure, T-SQL
You know how we've always heard that sp_msforeachtable and other similar undocumented functions may not be supported in future versions of SQL Server? Have you tried running something like this on any of your Windows Azure SQL Databases yet: EXEC sp_msforeachtable 'select ''?'', count(*) from ?' Try it out.
Read More

PASS Summit 2013 is Looking Cloudy

Azure, PASS
No, this isn't some complaint about PASS or the Summit. This is an announcement that not only will I be speaking at the PASS Summit, but I'm speaking about Azure... a lot. First up, I'm going to be doing an all-day pre-conference seminar specifically aimed at getting you into Azure. No, I don't want you to drop your on-premise databases and infrastructure. Are you nuts? No, wait, you think I am. OK, fair point. But what I actually want you to realize is that some pieces of your work are better done in the cloud. There are all kinds of terribly fun and cool things you can get done there, as an addition to your existing infrastructure. There are way, way too many things that are better done locally to ever think you'd move…
Read More

Microsoft Lync Through the Web

Misc
Get an invite to a Microsoft meeting? Are they using the new Lync interface? And, you don't have a paid Office365 account do you? So, you click the link, figure it'll open a web browser and off you go, right? Wrong. Instead it opens up a Lync app that you installed with Office, or the one that comes with Windows 8. And then you're stuck. You can't log in if your office doesn't have a Lync server (office?). Thankfully, there's a simple solution. Many thanks to Michael Wood. You just add a string to the end of the URL and you're off to the web app. I couldn't find this anywhere, so I figured I'd share with those who might need the help. Just add '?sl=1' to the end of…
Read More

Azure does Powershell too

Azure, PowerShell
Or, I guess it might be more appropriate to say that Powershell does Azure. Regardless, there are a set of commandlets for Azure and Azure SQL Database. Here's the link to get you started and the basic documentation. After that, it's a little tricky to know for sure what's required. Follow the instructions on the link to get the basic set up done, and then I'll show you just a little bit about how you can manage your Windows Azure SQL Database through PowerShell. First up, you need to set up a context, which is basically a connection to your Azure server. This requires very specific objects. The code below outlines what you need: $SQLLogin = new-object System.Management.Automation.PSCredential("UserName", ('12345' | ConvertTo-SecureString -asPlainText -Force)) $context = New-AzureSqlDatabaseServerContext –ServerName 'MyAzureServer' -Credential $SQLLogin…
Read More

Book Review: Business in the Trenches

Professional Development
I'm trying to improve. That's at just about everything too. I know I don't know enough or have enough skills to always get things done in an efficient manner, so I'm trying to learn more. One way is by reading, a lot. I've read a number of management and leadership books, many of them reviewed on this web site. I just finished the book Business in the Trenches. I really enjoyed it. It combined two of my passions, self-improvement and history, specifically history of World War I. Now, this is a tech, community and business blog, so I won't go on & on about the Great War (although I could if you wanted). Instead, I simply want to provide you a link to my review of this book. It really is a…
Read More

How to Tell Your Windows Azure SQL Database Moved

Azure
The very concept of the Windows Azure SQL Database (WASD) is predicated on the up-time created by having three active copies of your database. Should there be a hardware or software failure that would cause the primary replica to go down, your database gets moved to one of the secondary replicas which has been maintaining a copy of the data from the primary replica. In theory, the worst thing that happens is that you have to retry a query. In fact, building that sort of resilience into your code is a pretty fundamental aspect of working with WASD. I was asked the question, how do you tell if your database has been moved between replicas. I didn't have a complete answer, so I set out to find one. The first, more obvious…
Read More