Getting Started With SQL Server 2014 the Easy Way

Azure, PASS
You know you want to at least take a look at the new Client Technology Preview (CTP) of SQL Server 2014. I don't blame you either. I want to spend hours swimming through it too. But, you're thinking to yourself, "Heck, I'd have to download the silly thing, provision a new VM, walk through the install... Nah. Too much work." I don't blame you. I found myself on the road the day the software was released, so I was going to attempt to do all that work on a hotel wireless system. In short, I was going to have to wait, no options. Or were there? Actually, there is a much easier option. Azure Virtual Machines. And no, it's not that I can simply get a Windows Azure VM ready to go…
Read More

I Don’t Care

Azure
It's funny how certain sentences can both accurately reflect a situation and communicate entirely the wrong message. When thinking about cloud-based data management, things come down to a simple, if misleading, statement; I don't care. I don't care about operating systems or servers or disks. I need to have a database and it needs to be available and I need a reasonable assurance of performance. Within those parameters, I just don't care if the OS is patched or not, if the SAN is configured perfectly. I could care less if there are appropriate alerts on the internal network switches. None of that matters to me a whit. I just don't care about any of that because I'm focused on building a database and writing code and getting an app online. The infrastructure just needs to…
Read More

Azure First

Azure
Microsoft has been pretty clear about their commitment to the entire Azure infrastructure. The updates to Azure come out on a massively accelerated schedule. Because of this, they're doing lots of code on lots of things that may, one day, end up in your full blown SQL Server instance, but are currently only available in Windows Azure SQL Database. This is because of that accelerated schedule. It frees Microsoft developers up to experiment a little. I saw some evidence of it the other day. I had been working on a series of queries for the pre-conference seminar that I helped put on at TechEd (and one that I'm doing for the PASS Summit). When I write queries, I use SQL Prompt. Sorry to be plugging Red Gate products on the…
Read More

Using PowerShell to move files to Azure Storage

Azure, PowerShell
I was searching all over the place to try to find out how to move files into Azure Storage. Most of the examples I could track down were for API calls through C#. There were very few examples using PowerShell, and most of those were for older versions of Azure. But, the one thing I've learned about Azure, it's a fast moving target. Sure enough, in March there were new PowerShell blob cmdlets released. This is great news. I was able to get this to work: [System.Reflection.Assembly]::LoadFrom("C:\Program Files\Microsoft SDKs\Windows Azure\.NET SDK\2012-10\bin\Microsoft.WindowsAzure.StorageClient.dll") $account = [Microsoft.WindowsAzure.CloudStorageAccount]::Parse("DefaultEndpointsProtocol=https;AccountName=mystorage;AccountKey=mykey") $client = [Microsoft.WindowsAzure.StorageClient.CloudStorageAccountStorageClientExtensions]::CreateCloudBlobClient($account) $blob = $client.GetBlockBlob('container\adw.bacpac') $blob.UploadFile("c:\bu\adw.bacpac") But let's face it, this code makes more sense and is a heck of lot easier to write: $context = New-AzureStorageContext -StorageAccountName mystorage -StorageAccountKey mykey Set-AzureStorageBlobContent -Blob "adw.bacpac" -Container…
Read More

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

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

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