Category Archives: Uncategorized

It’s About Time for…#SQLSatOrlando!

Next week I am returning to Orlando not only to visit the mouse at his house, but also to speak at SQL Saturday Orlando! Last year was my first time there and I had a great time. This also happened after the event was pushed back to November 2016 because of Hurricane Matthew.

This year I will talking about deadlocking and blocking – something that is an issue for so many DBAs. Whether this issue is indexes or bad code…or you have been trying in use indexes to cover up bad code, blocks and deadlocks can happen in even the best environments under the right circumstances. If you are going to be at SQL Saturday Orlando come to my session where we will talk about detecting and preventing these arch enemies of the DBA!

AzureRM, PowerShell and Deleting Your VM the Easy Way

Before I worked on server migrations to Azure, I had only worked with Azure for a SQL Saturday session, and I was only using Azure as a host to the virtual machines (VMs) that I used to demonstrate PowerShell scripts running on a windows server that also accessed active directory. My only exposure to this technology was limited and focused on what I could do with the VM – not with how the VM was created or how I could use PowerShell to deploy a VM.

That professional experience with Azure finally came, and I got to work on PowerShell scripts that could be used to create VMs in Azure. With a script you have something that is consistent and less prone to human error, but even with that sometimes something is set up wrong that can’t be changed once the VM has been provisioned. Alternatively, maybe you are only using Azure for the testing of an application of project, you are done and the VM is no longer needed. You could simply decommission the VM, but if there is no need for the VM to still exist you probably want to delete it and all the parts associated with it.

The first one of these happened to me – there were three VMs where the configuration wasn’t right and it wasn’t something that could be changed from the portal. The VMs would have to be deleted and re-provisioned. I modified the creation script to have the right configuration for these VMs and got those created so work could continue. At this point I started to work on a script that would remove the VMs base on the name and resource group, including removal of all the parts that were tied to the VMs, such as the virtual network and the storage account.

Fast forward to today – I am working on my session for PASS Summit 2017. Instead of creating every part separately with the PowerShell cmdlets, PowerShell is used to apply a template that contains all the parameters and variables for a VM. If you need to make a change it is made to the JSON template, not to the PowerShell. Since I am testing, I am creating VMs and then I want to blow them away right after. I attempted to use the PowerShell script I had used before to remove VMs but that failed – enough time had passed that the cmdlets have been updated and what I ran before was no longer valid. I tried to revise the existing script and then ran across the OMG-I-can’t-believe-I-didn’t-do-this-before answer – just delete the resource group.

If you have contained all parts of the VM in the same resource group, and there is nothing else in the resource group other than the VM, cleanup is this simple. From what I recall about the server migration, there were multiple VMs associated with the resource group. If the resource group had only contained the VMs I wanted to blow away, I could have potentially run this for that clean-up operation. In this case, I was also removing disks from each of the VMs ahead of removing the VMs and had to run a script for that first. Looking back, if everything had been in one resource group, and had there been nothing else in there, I could have run this one line and been done.

For now, this solution works for me, but I know a more specific cleanup script may be more useful – one that will remove a VM and all of its parts based on the VM and the resource group. This will have to happen when I am done with my other testing, but in the meantime, this one line of code allows me to create and blow away VMs while using my personal Azure account…and not run up a ton of charges. Let me know if you find this useful or if you have any suggestions here – would love to have feedback!

PASS Board Elections – Voting Deadline is TODAY!

In case you have been under a rock, or buried in work, or otherwise occupied, the PASS Board elections are going on and end TODAY! There are some amazing candidates (thanks to the selection committee for all of their work in bringing us this fine list of folks) running for a handful of seats. Big question – have you voted yet?

When you vote you are exercising your voice and opinion on who from the SQL community best represents your views on the direction and future of the PASS organization. That said, the total number of people voting during each election cycle has steadily declined, with fewer that 1000 people voting last year.

With this being one of the easiest ways to be involved with PASS, you would think that these numbers would be increasing. If you have not voted yet, go check out the candidates. If you look at all of them, and just can’t decide who to vote for, give that Chris Hyde a second look – while it might seem like personal bias, I honestly feel he is well equipped for this position and will represent PASS and the SQL community with the same enthusiasm and vigor he has brought to the Albuquerque user group and all the other locations where he has spoken for user groups or SQL Saturday events (including the North Texas SQL Server User Group).

The voting deadline is 12 noon PST today (2pm CST). If you haven’t voted yet then put that query down and get to it!

Wanna Get the Kids Interested in Coding? Make it a Game. Literally!

Former co-worker and friend Daniel Janik is trying do something that I will eventually have to do – get a teenager interested in something that can lead to a career.

I’ve been teaching my 17 yr old SQL Server and other various topics. I have quite a bit of experience training technology and speaking but it never fails; after about 5 minutes his eyes glaze over and he nods and “umhums” and then starts checking his phone.

I have one nephew that is already intrigued by the PowerShell that I am doing and seems to have a genuine desire to write code. This makes me SOOOOOOOO HAPPY! My hope is that he is able to continue what he is learning now and migrate into a skill set that will afford him a good career. And if he happens to maybe “hack” into something that he shouldn’t have, I will help with his bail, smother him with hugs and kisses and tell him “OMG…I AM SO PROUD OF YOU!!!”

Check out Daniel’s blog post, download the game and give it a whirl. I plan on showing my nephews this to get the opinions of the younger, not-a-teenager set. I doubt my niece will be interested in this right now…unless there was a Disney princess in there with the sea monsters. I will leave it to Daniel to incorporate that in the 2.0 version. 🙂

 

Holy Blocking Chains, Batman – I’m Speaking at PASS Summit!

For the first time ever I will doing a general session at PASS Summit this year.

Waiting for an email with news one way or the other last week was angst ridden, to say the least. After receiving no notification with the first wave on Tuesday, I got even more anxious and tried to occupy myself with work and other things. I didn’t want to get excited over something that wasn’t even a thing yet.

Then late Friday – acceptance.

Yeah, that’s right. ME!

It didn’t sink in right away. I had myself so convinced I wasn’t going to get selected. Maybe my head and heart were still bracing for the disappointment that was not to happen. Why would I be thinking this way? This is the third time I have submitted and the first time I have had a general session accepted. I did have the opportunity of doing a lightning talk last year. I also got to compete in Speaker Idol, which was an amazing and valuable experience that is only available to those that have not done a general session before. More on this later.

The first year I submitted I had been writing abstracts the same way I normally did for SQL Saturday events, not knowing there was more involved for a PASS Summit abstract. I logged in and was about to fill out everything for each of my sessions when I saw all these fields to fill out that I didn’t know about. I quickly got things written for them, along with my main abstracts, and submitted.

But I didn’t get selected.

The next year PASS offered a program for feedback on Summit abstracts. I thought “Yes, this is great! I will write my abstracts, get feedback, and I will be speaking at Summit this year!”

But I didn’t get selected for a general session.

Both times I was disappointed. Both times I did a fair amount of sulking and grumbling, but I am only human. In these cases, my best was beat out by others that were better. Kind of a hard pill to swallow, but I think these challenges are what make us who we are – IT professionals that are constantly striving to improve our own skills while creating content that will convey knowledge and better the SQL Server community.

Last year however, I was selected for a lightning talk and I finally got to participate in Speaker Idol. Doing my lightning talk on How to Keep Your DBA from KILLING YOU was fun and a great experience.

Speaker Idol? Wow…how do I put this? If you are a new speaker, and have not spoken at PASS Summit before (general session or better), throw your name in the hat for this! If selected, you will have the opportunity to get up and present something in five minutes, and get immediate feedback from a panel of judges, who also happen to be well known and experienced speakers in the SQL community. When this was first done in 2014, I heard about the brutality of the first round, so I made sure I was there for the subsequent rounds. Your audience for this? Mostly speakers or aspiring speakers. Don’t be surprised if the final round is standing room only. Or if there are acrobatics (lookin’ at you, Rob).

Moving on to 2017…

Earlier this year it was announced that the Summit selection process was changing yet again. There would be no feedback to speakers and you were also limited to submitting three sessions. There was also a list of topics, with some marked as “hot topics” or topics that PASS really wanted content on. It was also stated that they wanted new content. That session you had been peddling to every SQL Saturday that would have you? Not new content.

I took all this info and combined it with a ramped-up abstract writing and review process. What is ramped-up? Reading the sessions that were selected last year, and having a reviewer that is a seasoned PASS Summit speaker. It also helped that my reviewer was super critical. Once it was announced that submissions were being accepted I logged in and grabbed all the sections that I would need to fill out and got started on my abstracts, outlining details before writing anything. There was even one session I outlined while on a plane, that I looked at later to write up and decided it was COMPLETE GARBAGE…AND WHAT WAS I THINKING???

What did I learn from the PASS Summit submission and selection process this year?

  • Review, review, review. Write them early, review, come back later and review again. Have other experienced PASS Summit speakers review your abstracts. Don’t like their feedback or think they are being mean? Ummmm….they are trying to help you get your abstract to a level that is worthy of PASS Summit. LISTEN TO THEM!!! And buy them a beer.
  • Nothing is guaranteed. In a previous blog post I told y’all how to pull all the submitted session into a table and even gave you some PowerShell code to do it. I was able to compare that to the list of speakers selected and there were some amazing people that have spoken and PASS Summit before that didn’t make the cut this year. Sessions are reviewed and selected by human beings. This is a gamble, and regardless of how good of an abstract you have, you are at the mercy of the session review committee and what they feel is good enough for Summit. This is a monumental task, but they hunker down and get it done so that all of us can have an amazing selection of sessions to pick from.

I hope I get to see everyone at PASS Summit this year, whether or not they are speaking. Out of the conferences that I have been to over the years, I have found PASS Summit to not only be the best of them, but it was where I discovered that the #SQLFamily thing is real. If you are open to it, you can get hooked into groups that will welcome you and include you all because you are there for the same reason they are – to expand your knowledge and career in the area of SQL Server.

See y’all in October!

Speaking – SQL Saturday Baton Rouge!

This Saturday will mark the fourth year that I will be speaking at SQL Saturday Baton Rouge at LSU. Out of all the SQL Saturday events I have participated in since 2014, Baton Rouge is one of the few that I have been to every year since. Houston is another one…and actually, these may be the only ones only because they have had an event every year.

Not only am I speaking on Automation with PowerShell and Deadlocks and Blocking, but I am also participating in a panel discussion on Careers in IT. I’m excited to be invited along with some of the other speakers to be a part of this. Looking back on my own school days, I knew I would have a career in IT, but little did I know I would detour from a path in development to the world of SQL Server, and becoming a DBA.

How do they make this happen? Work. Lots of hard work. After helping with SQL Saturday Dallas 2015, joining the NTSSUG board in 2016, and then having an organizing role in 2016, I found out how much goes into the planning of these events. If you have attended a SQL Saturday or you are going to in the future, be sure to say “THANK YOU!” to all the organizers and sponsors. If you want to get more involved in the SQL Server community, SQL Saturday is a great way to do that – just show up at the event, find an organizer and tell them that the SQL Kitten sent you to be their humble servant volunteer for the day…or you could just say you want to volunteer and leave out the other stuff because it might make it weird.

(UPDATED) PASS Summit 2017 Session Data (You know you want it…so go get it!)

UPDATE #1 –
The following changes were made to the PowerShell script for the PASS Summit 2017 session scrape:

  • Abstract field is now varchar(max). ‘Cause precons get all the chars.
  • Added SubmittedSession column.
  • Upper bound increased to include precons.

UPDATE #2 –
Before I could get update #1 posted, it appeared all the general sessions and lightning talks were removed from the submissions page and replaced with submitted precons. Don’t fret – the PowerShell script will still grab all the submitted sessions (for now). There were also some more precons added so the upper bound has been changed yet again.

 

The deadline for PASS Summit submissions came and went. Either you got yours in or you didn’t. What does this mean? Time to gather the data.

Go get it! You know you want to!

Never having done a web scrape before, this was the perfect subject for my first time – grabbing all the sessions submitted to PASS Summit 2017…and doing it with PowerShell! Here is the script I used for this. I have accounted for the following:

  • Apostrophes (aka single quote). They will break your insert unless you have two of them, and for some reason, people seem to use them all over the place.
  • Formatting the string data for insert. No, your data will not magically come out right in your insert with single quotes so you need to add them.
  • Additional ID and deleted fields.
  • Speaker URL and ID. Will be using this to scrape speaker details later.
  • Accurate lower and upper bounds. These were arrived at by trial and error (you’re welcome), as well as the clean up of the data I scraped. More on this later.

Now for the code –

 

There will also be some webids that error out – this means the session doesn’t exist for that specified webid. You will see an error in the output to the PowerShell window, but the script will keep running.

Once you run the script and it completes, you will have your table of session data. You will notice that there are more sessions there than have been submitted, according to the website. If you do a count of the sessions by speaker you will also find that there are more than three sessions (the maximum allowed) for quite a few speakers. Why is this? You are pulling from a data source that contains sessions other than the ones that were submitted to Summit (apparently). This means you will have to clean up the data – I included the deleted field for this purpose. Look at the duration and filter for the 75 minute and 10 minute sessions and update your deleted field accordingly.

After this, you will have sessions that meet the duration, but you will find the speaker is not listed on the submission site when doing an advanced search. Clean the data some more.

Are you done cleansing your data yet? You might think so, but you aren’t. You see sessions that look like they were submitted for Summit but are not on the site. These appear to be sessions that were created and saved, but not officially submitted. You can rule out quite a few of these if you look for speakers that have more than three sessions. Get those counts, check the website for those speakers, and clean your data.

“Good lord, am I done yet?”

No. No you’re not.

There will be speakers that have three sessions in your table but only submitted one or two. This sounds worse than it is, but it is a little painful. How do you do this? You’re going to search the speakers with the advanced search on the website. Do these in groups based on the number of sessions a speaker has, ordering by speaker name. You can exclude the the speakers you have already reviewed in the previous clean-up steps, deleting their names from your list as you go. When you find a speaker with three sessions in your list and fewer sessions submitted, mark the session that was not submitted as deleted. Next, do the speakers with two sessions as they may have only submitted one. Finally, look at the speakers with one session as there may be ones that didn’t officially submit anything.

“But what about the code for the clean-up?”

No. You know how to do this, and may write it differently (and better) than me. My code was ugly and I don’t feel like cleaning it up and posting it here. I gave you the script to grab it all. Stop complaining or I will send you to time-out.

The speaker info grab will be a separate blog post. With the script in this post you might be able to use the syntax and craft your own PowerShell script for this. Or you could wait for my blog on it.

Yeah…I haz the datas!

SQL Saturday NEW YORK CITY? Get a rope!

This weekend I will be speaking at SQL Saturday New York City. My last time here was two years ago for the last SQL Saturday here and I had a great time. If you are in the area come on out for some awesome speakers and a great day of learning!

Anyone remember this? No? Just me, huh? Ok.

Blogging reboot and PowerShell – Get System Information

After whining about not blogging enough, I am going to do something about this. Whether it is PowerShell or SQL, simple or complex, I know that others can benefit from my knowledge and expand their skill sets.

And you are like “That’s great Amy…where’s the PowerShell we are here for?” Ok, Ok….keep your drawers on! 😉

Recently I was tasked with gathering the system information from all of the servers at a client. Another opportunity for some PowerShell dominance.

With this script you can generate system information files and save them to a specified location. It makes sure a connection can be made to the server first, and then outputs the file. The files are created one at a time, so if you pass in a longer list of servers, you shouldn’t crash your machine. From my testing, this will take some time to run as these files don’t output quickly. Despite that, the output is worth it. This can be modified to pull your list of servers from a file or from a Central Management Server (CMS) instance.

Hope you find this useful. Happy PowerShellin’ 🙂

Cannot drop the database because it is being used for replication – the Right Fix and the Long Way

One of the things I am still trying to get past when it comes to writing about tech is the fact that I can’t always be completely original. I can write about different experiences and scripts but in many cases someone will have already written about the same thing. Part of tech blogging is realizing that even if someone else has already written about something you want to write about WRITE ABOUT IT ANY WAY. Maybe you had a task that was slightly different from what others have written about or maybe you can embellish on something they left out. Bottom line, you can be creative and reach people.

Another part of tech blogging is the fact that sadly there are people blogging about the wrong other ways to resolve certain issues. Your parents told you not to believe everything you read on the internet – are they liars or is that “expert” telling you the best way to do backups is with maintenance plans the one serving up the bull?

I had been asked to detach a database. The person doing it couldn’t and tossed it to me. Cool. No big deal. Then I ran the script to detach and got the error message 3724 – Cannot drop the database because it is being used for replication.

Well, isn't that special.

Well, isn’t that special.

Was there replication? Yes. Were there any publications associated with this database? There used to be but not any more (at least not visible at the publisher server in SSMS). There were some other issues that needed resolving but those had nothing to do with this situation. I pop over to my other screen and start looking for the right scripted solution (I figure I will have to do this again so better that I save it off to a script with some notes).

First, I want to show that the database is enabled for replication – sp_helpreplicationdb is going to give me this information.

help

Ok. Now what?

Based on the results from sp_helpreplicationdb , I now have confirmation that my database is at least enabled for replication. The next thing I need to do is turn off replication for this database with sp_removedbreplication.

Fixed - WITH ONE LINE OF CODE!!!

Fixed – WITH ONE LINE OF CODE!!!

After ran this I was able to detach the database. And all was right with the world. On Saturday night. Did I mention this was on Saturday night? I’m a party animal.

Anyways, back to the tale of the long way to do this…after my search I had opened a few of the results in new tabs in my browser. One of them was here. After a little more searching based on this link I had what I needed with the right syntax. I resolved the issue but when I was done I still had to go back and close the new tabs I had just opened. It was then that I saw a completely different solution. While this other solution may have allowed you to drop the database, it required far more steps than the one I presented above. Also, in my case, I did not want to drop the database, just detach it. Restoring the database from a backup that contains no data wipes out my database, and was not part of the requirement. So essentially, to be able to detach the database I would have to run sp_helpreplicationdb and sp_removedbreplication OR I would have to take a backup, validate that all the data that was needed was in the backup, create the other database, backup that database, copy the backup file, restore the backup with replace over the database I am trying to drop, and then detach or drop the database. In this case, the desired end result was to migrate the database files to a new server and attach them. This would be changed to restoring from the backup of the original database. If you have a case where you are having to do this for multiple databases, this would be multiplied.

Frustrated after finding this, I took to twitter.


I decided I would do the right thing and give the internet one more page with the RIGHT SOLUTION. While we can’t stop people from posting the longer, less practical solutions to things we can post the right ones and keep posting them.

candy

They might have a few pieces of candy left.

Now that we have established the internet lies to you, go call your mother.