Category: Blog

  • Pro SQL Server on Linux- More Installs

    As part of my learning goals for 2018, I wanted to work through various books. This is part of my series on Pro SQL Server on Linux from Bob Ward.

    After my last post, I decided to try and install the SQL Server 2019 preview version and see how that worked. I followed the instructions from Books Online.

    Adding a new Repo

    At first, I used curl to get the new repo file and then run the install. When looking at the install (sudo yum install –y mssql-server), I wondered if this would know I wanted 2019 instead of 2017. At this point,  my system has two repos, so how does it know?

    No idea, but it worked.

    2018-12-20 14_32_09-RHEL74 Bob - VMware Workstation

    Or did it?

    2018-12-20 14_35_41-RHEL74 Bob - VMware Workstation

    I think I upgraded my instance, which is fine. This is testing, so it works fine for me.

  • Sorting Values in a Column

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers.

    This was a post that caught my eye, since I’d just written a piece on STRING_SPLIT(). Someone had this data:

    DECLARE @Names VARCHAR(8000) = 'Steve, Grant, Kathi, Kendra';

    They wanted this returned as a string that was sorted, so that the values would be:

    Grant, Kathi, Kendra, Steve

    String manipulation isn’t the strength of SQL Server, but we can do this with STRING_SPLIT(). If we use STRING_SPLIT(), we get a list of values. We want to remove the spaces after the comma, so we use REPLACE to remove that.

    SELECT *
    FROM STRING_SPLIT(REPLACE(@Names, ' ', ''), ',')
    ORDER BY value;

    We can then aggregate these back together in a variable assignment, adding the comma for each row.

    SELECT @newtext = @newtext + Value + ', '
    FROM STRING_SPLIT(REPLACE(@Names, ' ', ''), ',')
    ORDER BY value;

    This gives us:

    2018-12-21 15_05_08-SQLQuery1.sql - Plato_SQL2017.sandbox (PLATO_Steve (55))_ - Microsoft SQL Server

    SQLNewBlogger

    A quick T-SQL application of some skills I learned. Can you do something similar? Maybe order dates or numbers that are in a string in the wrong order?

    That should be a 10-15 minute post.

  • Pro SQL Server on Linux–Install

    As part of my learning goals for 2018, I wanted to work through various books. This is part of my series on Pro SQL Server on Linux from Bob Ward.

    I had an Ubuntu VM setup at home, but it started to flake and eventually stopped responding as a desktop. Since I’m not a Linux expert, I wasn’t sure what to do and really didn’t think it was worth debugging a broken Linux OS. Instead, I moved on.

    In the book, Bob uses Red Hat Linux, so I downloaded RHEL and installed it, after going through the process of joining the Red Hat Developer network. If I don’t do this, I only get a 30 day trial, which I didn’t want. I get the process, and understand them making money.

    For a lab, it was a pain. This made me want to go back and just get Ubuntu.

    2018-12-20 09_15_22-RHEL74 Bob - VMware Workstation

    In following the install instructions, I started with getting the Microsoft registry set up. I got an error when downloading the repo file.

    2018-12-20 12_34_30-RHEL74 Bob - VMware Workstation

    From this link, I added my user with

    usermod –aG wheel sjones

    2018-12-20 12_37_49-RHEL74 Bob - VMware Workstation

    Had to change the network to bridged in VMWare. Not sure why, but this is how I have a few VMs set, so I just matched this.

    Subscription

    I needed to attach my subscription. I started by registering, which was fun. I had to go back to the Red Hat portal, log off and back on.

    2018-12-20 12_48_12-RHEL74 Bob - VMware Workstation

    Then dependency errors. Isn’t yum supposed to resolve this?

    2018-12-20 12_45_08-RHEL74 Bob - VMware Workstation

    The key is that I wasn’t getting updates. I had to run

    subscription-manager attach –auto

    which linked my system to the update system. I can see how Red Hat makes money. This feels as onerous as Windows for management and product key matching. In any case, this allowed the install to proceed:

    2018-12-20 12_58_20-RHEL74 Bob - VMware Workstation

    Eventually this completes, which is a welcome sight.

    2018-12-20 13_02_00-RHEL74 Bob - VMware Workstation

    One note, when trying to get the dependencies, I removed the –y option for the install. Once things worked, I had to answer “y” to a lot of questions, so you’ll want that enabled.

    Configuration

    The next step is to configure your instance. I started this, but it didn’t quite work.

    2018-12-20 13_04_13-RHEL74 Bob - VMware Workstation

    If you look, you’ll see the failure message is that we need 2000MB (2GB) of memory. The VM has 2048, but that’s not enough. I reset this to 3072MB and the config worked.

    2018-12-20 13_07_57-RHEL74 Bob - VMware Workstation

    Validating the Install

    From the book, the first step is to check the service.

    2018-12-20 13_12_04-RHEL74 Bob - VMware Workstation

    The the process.

    2018-12-20 13_12_33-RHEL74 Bob - VMware Workstation

    That’s good, so I followed instructions to install tools. This ran off the screen, so I didn’t bother capturing a screenshot, but it worked according to instructions.

    Next, connect to SQL Server and check the version.

    2018-12-20 13_54_05-RHEL74 Bob - VMware Workstation

    Tada. Well, not that exciting. The process was more annoying than I expected or remembered, but most of that appears to be RHEL more than SQL Server.

    However, this was a nice test and project, with no GUI on the system. Looking forward to doing more with this across the month.

  • Automation for Databases–T-SQL Tuesday #110

    tsqltuesdayThis is the day for T-SQL Tuesday #110, a topic picked by Garry Bargsley. Automation has been a cornerstone of most of my career. As much as I work hard, and don’t mind putting time and effort into accomplishing tedious work, I also know that automation makes my life much, much easier.

    And me a far more productive employee.

    Automation is king, so here’s one place I’ve used this in the past.

    Complying with Standards

    One of the big items auditors want to have is proof that this thing happened or didn’t happen. That an employee actually performed some action, with some proof. At one point, we were being audited and I was asked if we checked that all backups were running for all databases.

    Of course, most backups worked, some failed,  and we were aware. More importantly, I could prove it. In our Exchange Public folders, we had a folder for database actions. In here, for each day, was a report from each database server. If there was a question of compliance for any of our sensitive systems, we could give them a link. More importantly, anytime we ran a remediation, we posted a note and the scripts run for the system. That way any backups that failed and were manually run, or other changes, were logged.

    This was a combination of a T-SQL querying system DMVs and DBMail to send out reports to our public folder (and DBAs). Today, if I needed something similar, I might move to PoSh, but likely lots of this is still easy to accomplish in T-SQL. However, I’d really rather not build any more monitoring systems. Too many things to manage, and my time is better spent.

    Now I’d use SQL Monitor and if anything, build my own reports on top of that infrastructure. That way the data gathering, archiving, etc. isn’t something I need, and I can extract out the text reports for auditors, which they like. Plus, with automation, they know that the system is running as intended.