Author: way0utwest

  • Using Better Tools

    There are good tools available to help you work with your SQL Server database or build better applications. Microsoft has built some, most of which I think are basic and not great, but plenty of third parties have offered products in the Microsoft ecosystem that can help you build better systems. I work for a software vendor (Redgate Software). We build all sorts of tools to help you work with SQL Server. I enjoy working for Redgate because I think we build some great software that’s valuable, and I hope you check us out. Most of our our utilities cost money, but we have some cool, free tools, like SQL Search and DLM Dashboard.

    I get that some organizations don’t have the budget for third party tools. That’s too bad, but there are some good tools out there, and I think many of us vendors do provide value in saving you time and effort in working with the Microsoft platform. If that’s worth the cost, you should consider using tools. At the very least, you should be aware of the free and paid extras out there and consider the ones that help you.

    What I find strange is that some orgs don’t allow any third party tools, free or paid, because they don’t come from Microsoft. They may even disallow utilities like sp_Blitz, sp_whoisActive, and the dbatools project. What I don’t understand is why there is a blanket ban on software from companies other than Microsoft? How can you not take advantage of these tools? I get that many companies might not want a developer or DBA installing some random software on their system whenever they want. There are good reasons to not do that, but there are also good reasons to test and use actual code that is useful, even if produced by someone else.

    What’s also interesting is that rarely find an issue with Ola’s backup scripts, so why would Minion Backup or these other tools be different? After all, most of these are open source, so you can see the code. It’s really no different than the code that an employee might write, howover many companies don’t have employees that can write this software. You can see the Powershell for dbatools on Github, so what’s the issue? You can test this code like you might test your own code. In fact, you should aways do this, but you can also count on other people having tested this code as well, perhaps in ways you wouldn’t think of exercising it. You might even be doing this, with employees cut and pasting code from one of these utilities on your system and passing it off as their own work.

    Every company might need restrictions on code that goes to production systems. Certainly they should have ways to patch and update this code, especially as many of the issues found from open source software stem from organizations not applying patches. All code should be tested and verified, whether written by FTEs, contractors, purchased, or downloaded from the Internet. However, once you can verify code, there shouldn’t be restrictions on deploying code just because it wasn’t written by Microsoft. After all, many in the community might write better code than Microsoft, and often do.

    Take advantage of the tools that are out there. Use free ones if you can and buy third party products if they give you value for your money. However, don’t just say that we can’t install something because it’s not on the install media. Your build process should be scripted, treating configuration as code, and add those useful (tested) tools to all your systems.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 4.8MB) podcast or subscribe to the feed at iTunes and Libsyn.

  • Creating a Books Online Pull Request

    One of the neat things at Microsoft did last year was put Books Online in GitHub. This is in the MicrosoftDocs org under the sql-docs repo. The organization is a bit funny, but once you get used to it, you can find the docs.

    One of the neat things that is available now is that anyone can edit Books Online. You can’t edit the live versions in GitHub, nor the versions published on Microsoft’s site (or downloaded), but you can submit your changes as a pull request, which Microsoft will review the changes, and if they like them, the changes can get added to the official docs.

    This post shows how you can do this.

    Requirements

    First, you need a Github account. This is free, and you will end up with a fork (copy) of the official repo in your account when you edit.

    Second, you need to learn a little markdown. Not much, but enough to make formatted changes. I like this cheatsheet, but there are plenty out there (kidding).

    Editing BOL

    When you go to a page in the online BOL, you should notice a short menu in the upper right. It has Feedback and Share links, but also an “Edit” link. You can see this in the image below.

    2018-01-02 12_30_06-BACKUP (Transact-SQL) _ Microsoft Docs

    If you click Edit, you’ll be taken to the page in Github. Below, I have the Backup page shown. Note the path near the top (by Branch:live) of sql-docs/docs/t-sql/statements/backup-transact-sql.md. This is the file in the repo. You’ll need this.

    2018-01-02 12_31_01-sql-docs_backup-transact-sql.md at live · MicrosoftDocs_sql-docs

    This is the real repo from Microsoft, and you won’t be able to edit it. If you click edit (a pencil icon on the right side, just above the doc and to the right of the Raw|Blame|History buttons, you’ll get this:

    2018-01-02 12_33_28-Editing sql-docs_backup-transact-sql.md at live · MicrosoftDocs_sql-docs

    That’s fine. You can edit the page and then save this in your copy of the repo. In this case, I actually wanted to edit this page to add the NUL device. I scrolled down and found the area I wanted to edit. For ease of viewing, I’ve highlighted the place I edited the file.

    2018-01-02 12_34_28-Editing sql-docs_backup-transact-sql.md at live · MicrosoftDocs_sql-docs

    Commit

    All of you reading this should be familiar with version control. If you’re not, learn that.

    To commit my change, I scroll to the bottom of the file and I’ll see the propose file change dialog. I can enter a title (meaningful for the change) and a comment that will let someone know what I’ve done.

    2018-01-02 12_36_17-Editing sql-docs_backup-transact-sql.md at live · MicrosoftDocs_sql-docs

    Once I do this, a new branch is created in my repo. If I look at the result page, I’ll see this:

    2018-01-02 12_37_02-Comparing MicrosoftDocs_live...way0utwest_patch-4 · MicrosoftDocs_sql-docs

    Reading this, I see that in my fork (way0utwest/sql-docs), I have a new branch (patch-4) that was created. Below this are the details of the commit, but essentially I have a copy of the official Microsoft repo in my area, with one new commit.

    The Pull Request

    A pull request (PR) is a notification to a repo that there are changes that someone wants to merge into that repo. In this case, a pull request will let MS know that my change is ready to merge, and they can review it.

    To start a PR, click the green button in the image above. By default, I’ll get the same commit comments I had listed above. In this case, I see this:

    2018-01-02 12_39_30-Comparing MicrosoftDocs_live...way0utwest_patch-4 · MicrosoftDocs_sql-docs
    Note, there are a couple important things here. First, this change is “able to merge”. We see that near the top. If you’ve made substantial changes that don’t necessarily merge cleanly, or you have an old copy of the repo, this won’t work. Go back and create a PR to update your repo from MS (you can approve this) and then make your changes.

    Second, make sure that your comments make sense to the person that will review this. In my case, I wanted to have more complete docs with NUL as an option (since it is) and I noted this is a target. I could expound why here or add more details. I try to ensure each change I’ve made has a sentence, so if I added a note to a different place in the docs, I’d have a second sentence here.

    Click “Create pull request” to complete this. Someone at MS will be notified, and you’ll get an email. In my case, I got this:

    2018-01-02 12_25_27-Deleted Items - steve.jones@red-gate.com - Outlook

    Waiting

    The next step is to wait. I’ve submitted four or five minor PRs that helped complete or clarify docs. In some cases I got a note from the repo maintainer the same day, some took 3 or 4 days.

    In any case, you may get a message that your change is accepted and it’s been merged. In this case, you’re done and I thank you for improving BOL.

    You also may get a message back in your PR that there are other changes that need to be made, or on rare occasions, an conflict has occurred. In that case, you may need to edit your change, make a new commit, and a new PR.

    This is a great model that Microsoft has given us to allow the community to issue corrections. Prior to this all feedback would get emailed to someone at MS, without any real organization. Or MVPs would send in feedback, but someone would need to interpret that and make a change. Now the community can easily make a change and help improve and correct our docs.

  • No Magical DevOps

    I saw this comment in a post a short while back. A reader said “I’m still trying to wrap my head around “devops” as it pertains to database deployment. … how do you deal with those potentially dangerous/destructive changes without manually coding? … what tools are there that help in that regard? That’s what database developers really need. The only tools I’ve found that’ [are] useful so far are experience and care.”

    We have some tools over at Redgate software to help with database DevOps, but there aren’t any magic solutions that can alter your database in some way that doesn’t impact users and preserves all data. In fact, if anyone claimed to have a tool, I wouldn’t trust it because there are just too many variables in database deployments. I certainly wouldn’t trust a tool with automated rollbacks. Ultimately, experience and care are needed to build better software.

    And, by the way, DevOps doesn’t solve deployment issues. All DevOps does is help you automate the tasks you’d run manually in a reliable, repeatable fashion. DevOps teaches you to learn from your actions (gaining experience) and experimenting with small changes so that your mistakes aren’t as impactful (developing with care). DevOps isn’t magic, it’s good, solid, learning from what works and what doesn’t, altering our habits, and striving to be better. DevOps is often just providing a reliable, repeatable way of automating the things you do manually now, not inventing new processes.

    I do believe in DevOps and I think that it can work well, but it requires balance, commitment, and huge culture changes. Automating code deployment is easy with some tools. Getting people to write better code is hard. I can help with the former, and I try to help with the latter here at SQLServerCentral, but it’s really up to most of you to make an effort to become better at your craft. Getting that to work in any size organization requires that your management supports teams learning to be better and tolerating a few mistakes here and there.

    Many successful developers and DBAs have been practicing for many years (even decades) what the media and high profile companies have been calling DevOps for mere months. You can join them by looking to improve all parts of your software development pipeline through collaboration and automation. Just don’t forget to also learn to write better code along the way.

    Steve Jones

    The Voice of the DBA Podcast

    Listen to the MP3 Audio ( 3.5MB) podcast or subscribe to the feed at iTunes and Libsyn.

  • Starting from Scratch

    As the new year starts today, I find myself looking at my blog and seeing no posts in queue. My last editorial published today and no blogs scheduled for this week. In other words, the same state that many blogs are in.

    I’m a big fan of writing regularly, and if inspiration strikes and lets you get more than one post done, schedule it out. Usually I’ve got 5-10 posts scheduled at any one time, but not today. With two weeks of travel and then holidays to close out 2017, I didn’t do much writing.

    So today the focus is getting back to work, while also keeping an eye out for those things to write about. As I work with T-SQL, I’ll make notes of things that are interesting, or that I learn, and start adding blog posts.

    I don’t have a goal for 2018, but I did end up with 219 blogs (excluding editorials) with an average of 18 posts a month. We’ll see how I do this year.