sqlserver

I Will See You in Seattle!

A few weeks ago, I teased good news. just got some good news. can't wait to share it — Andy Levy (@ALevyInROC) July 20, 2018 One person hypothesized that I’m joining Microsoft (it seems to be the thing to do lately) and another jumped to the conclusion that I must be pregnant. Both creative responses, but not quite correct. I’ll be at PASS Summit 2018! So much to do! Pick some sessions Make my checklist of #sqlfamily I need to see Find a way to pack lighter (I think the iPad will stay home this time) Up my selfie game Get back into shape for #sqlrun Print up some more dbatools ribbons Figure out the social media photo situation (see above, “Up my selfie game”) If you’re attending Summit, let’s meet up!

Triggers vs. Default Constraints: Choose Wisely

Andy Levy
Triggers can be really useful in your database but you have to be careful with them. We often use them to record history to a separate table (at least, until we can implement temporal tables) or keep track of when a record was last updated. It’s usually implemented via an AFTER UPDATE trigger. Several times a day, I’m alerted by our monitoring suite that two processes were deadlocked. This is a (mostly) normal event, but one that we’d like to avoid if we can.

Quick Table Info Export with PowerShell

Andy Levy
This week I had a user come to me asking about how fields were defined on a few tables he was using in writing some reports. Long story short, he’s been tasked with writing some new reports and updating existing ones, but he doesn’t have visibility to the database itself so he’s left with the “ok, let’s try this” approach and then reading error messages to debug when things go sideways.

My First Migration with dbatools

Andy Levy
I’ve been a proponent of dbatools for close to a year now and even contributed to the project, but surprisingly haven’t been a heavy user of it. Mostly due to a lack of opportunity. I’m aware of many of the functions by virtue of working on the built-in documentation and following the project and presentations about it. So when the need arose to move a development/test instance of SQL Server from a VM onto a physical server, I knew exactly what I wanted to do.

dbatools Badge Ribbons at PASS Summit

Andy Levy
One of the (many) fun things to do at PASS Summit is to check out the ribbons people have attached to their badges. Some are witty or goofy, others informational, others technical, and still more that let you express how you identify with a community within the community. To celebrate dbatools and the awesome team & community around it, two limited edition badges will be available from/distributed by me and a handful of other folks all week at Summit.

T-SQL Tuesday #92: Lessons Learned the Hard Way

Andy Levy
This month’s T-SQL Tuesday is hosted by Raul Gonzalez and he’s asked everyone to share things we might be a bit embarrassed about: For this month, I want you peers to write about those important lessons that you learned the hard way, for instance something you did and put your systems down or maybe something you didn’t do and took your systems down. It can be also a bad decision you or someone else took back in the day and you’re still paying for it…

Don't Forget the Network

Andy Levy
A few weeks ago I was looking at a query and got tripped up by the network and my own forgetfulness. It was a pretty simple query with a simple-looking execution plan. It didn’t even do that much work. About 20K logical reads and returned 200K records. For a server as large as the one I was working with, this should have been nothing. Instead, was waiting three minutes to get my results.

I Finally Get Cross Apply!

Andy Levy
For years I’ve looked at various queries online in sample code, diagnostic queries using DMVs, and the like and seen CROSS APPLY in the FROM clauses. But I’ve never really managed to comprehend what it was for or how it worked because I never saw a case where it was directly applied to something I was doing. Finally, this week I had a breakthrough. I was working on updating a bunch of data but it was breaking on a small subset of that data.

Adding Application Name to Invoke-SqlCmd2

Andy Levy
In a previous post, I expressed some frustration over Invoke-SqlCmd not setting an Application Name for its ODBC connection, leaving us with the generic .NET SqlClient Library when looking at active sessions in sp_who2 and sp_whoisactive (and any other monitoring tool). Unfortunately, I can’t really do anything about Invoke-SqlCmd aside from posting a suggestion on Connect or the Client Tools Trello board, but Invoke-SqlCmd2 has the same issue and that’s on GitHub.

Make Your Application's Name Heard

Andy Levy
Odds are, you’ve got more than one application or script accessing your database or SQL Server instance at any given time. You’re probably stacking them on a small number of servers in an attempt to cut down on licensing costs and resource usage. All those PowerShell scripts running on the central job server are running under a single service account, and you’ve got a lazy vendor who set up both the website and back-end application server to run under the same account, maybe even on a single app/web server.