Category: Blog

  • Packt $10 Sale

    One sale today, my Getting Started with SQL Server 2016 Administration video. You can get this for $10 today, and it’s an introduction to an overview of what’s in SQL Server 2016, most of which applies to 2017 as well.

    Covers basics of administration from install and configuration to security and XE. If you have a junior that’s not worked much with SQL Server, this might help.

    Outline:

    1. Installation – GUI and CLI
    2. Login, Users, and Roles
    3. Databases, configuration and creating objects including CLR code.
    4. OLTP Tables
    5. Indexing Basics
    6. Backup and Recovery
    7. Agent, Jobs, and Operators
    8. HA technologies in SQL Server
    9. TDE, Always Encrypted, Column encryption, Row-Level Security, Dynamic Data Masking
    10. Extended Events
    11. Execution Plans and Query Store
  • SSMS 17.4 Vulnerability Assessment

    SSMS 17.5 is out as of February 2018, but the the Vulnerability Assessment (VA) was released in SSMS 7.4

    It seems that the Microsoft tools team is trying to build us better tools that come with the platform. There are good third parties that build tools, such as my employer, Redgate Software, but I am glad that Microsoft is also providing a little more value. This is especially welcome in the area of security.

    In SSMS 17.4, the upgrade came with one goodie: the VA. This is an analysis that will help you determine if you potentially have issues with your instances and databases. This is an assessment of a database, but there are server implications as well.

    Once you install or upgrade SSMS, you can right click on a database and choose Tasks, Vulnerability Assessment.

    2018-02-23 17_37_53-

    This is actually a menu of a couple items. You have the choice to run a scan or open an existing scan that you might have saved on your system.

    2018-02-23 17_38_29-SQLQuery4.sql - (local)_SQL2016.AdventureWorks2014 (PLATO_Steve (70)) - Microsof

    When you run a scan, a new dialog opens that asks you where to save the scan. You can change the path, and once you click OK, the scan runs.

    2018-02-23 17_39_14-Scan For Vulnerabilities

    A new tab opens in the query window space with the results of your scan. This gives you the bad news first. Those items you failed. In my case, I had 5 items.

    2018-02-23 17_50_17-Vulnerability Assessment - BaseballStats - 2_23_2018 5_39_26 PM - Microsoft SQL  

    These items are listed as high, medium, or low risk. I haven’t dug into these too deeply, so I won’t comment on the appropriateness, but look for more information at SQLServerCentral soon.

    I did better on the passing side, 49 items.

    2018-02-23 17_50_25-Vulnerability Assessment - BaseballStats - 2_23_2018 5_39_26 PM - Microsoft SQL

    If I pick an item, I can mark this as approved as the baseline setting. For example, on this instance, I want Remote Admin connections.

    2018-02-23 17_52_32-Vulnerability Assessment - BaseballStats - 2_23_2018 5_39_26 PM - Microsoft SQL

    If I click “Approve as Baseline”, I get a dialog. I’ll say yes.

    2018-02-23 17_52_38-Approve as Baseline

    This item now has a baseline marked, or rather, the absence of a baseline removed. I also get a note that there are changes near the top.

    2018-02-23 17_53_26-Vulnerability Assessment - BaseballStats - 2_23_2018 5_39_26 PM - Microsoft SQL

    If I run a new scan, this issue doesn’t appear.

    2018-02-23 17_54_24-Vulnerability Assessment - BaseballStats - 2_23_2018 5_53_44 PM - Microsoft SQL

    This is now an item in the Passed tab.

    2018-02-23 17_54_52-Vulnerability Assessment - BaseballStats - 2_23_2018 5_53_44 PM - Microsoft SQL

    This is simple, and perhaps trivial, but having this built into a tool means that you can now start to see if things change. There is likely lots of opportunity to build on top of this and perhaps aggregate data or make it more consumable. Look for other companies to add to this, but for now, it’s nice that Microsoft is adding security help to SSMS.

    You can read more about the Vulnerability Assessment on docs.microsoft.com.

  • Data Masker for SQL Server–Syncing Values Across Rows

    I’ve been playing with Data Masker for SQL Server v6 and it’s an interesting product. I like the way it works, but I do find it a little challenging sometimes to figure out how to mask values. I’ve written a set of posts for different scenarios.

    We had a customer ask about how to mask data across rows. The customer had some data in a table that was a standalone table, and contained data in a column that matched across rows. They wanted this changed, but the matching between rows kept.

    In other words, here’s a small mocked set of the original data:

    myid        Mychar     myint       mytinyint
    ----------- ---------- ----------- ---------
    1           Steve      12345       1
    1           Steve      12345       2
    2           Andy       12345       3
    2           Andy       12345       4
    3           Brian      12345       5
    3           Brian      12345       6
    3           Brian      12345       7

    Here are the results they want:

    myid        Mychar     myint       mytinyint
    ----------- ---------- ----------- ---------
    1           aaa      12345       1
    1           aaa      12345       2
    2           bbb       12345       3
    2           bbbb       12345       4
    3           ccc      12345       5
    3           ccc      12345       6
    3           ccc      12345       7

    I thought this was an interesting scenario, so how do we mask this? It’s not that hard, so let me show you this.

    First, let’s create a new masking set. I won’t walk through that here, but once you have a set connected to your database, here’s what we do.

    First, we need to substitute data out. In this case, I’ll substitute the name only. In a real world, we’d probably need to substitute the myid and myint columns as well, but I’ll leave those again.

    I add a new Substitution rule first.

    2018-03-02 15_22_05-Edit Substitution Rule

    This is a standard rule. I’ll add my column and pick a dataset. In this case, I’ll just pick make first names (Names, First, Male) and use that. This will result in a random set of names. I’ve chosen unique values. This is important as across a large number of rows, I could end up with random values that match, but with different MyID values. That would be bad.

    If I save and run this rule, I’ll see something like this.

    2018-03-02 15_25_04-SQLQuery1.sql - DKRSPECTRE_SQL2016.sandbox (DKRSPECTRE_way0u (52))_ - Microsoft

    Not quite what I need, but it’s a start. The important thing is that the first myid=1 is different from the first myid = 2, which is different from myid=3.

    Next we’ll add a Table Internal Sync rule. This is the rule that fixes values across rows inside a table. Here’s the basic config. Note that I choose a table and then I choose the columns that need syncing, in this case just the mychar column.

    2018-03-02 15_27_22-Edit Table-Internal Rule

    I need a way to determine which sets of rows should match. In this case, the myid column is used for that. If you examine the initial set, I have the same values for each name. This is what groups things together, so I’ll use this.

    One Note: The red “I” to the right means this isn’t an indexed column. If I wanted better performance, I can add an index for this column, either permanently or just for the masking process.

    Now I execute this rule, and I see these results:

    2018-03-02 15_31_18-SQLQuery1.sql - DKRSPECTRE_SQL2016.sandbox (DKRSPECTRE_way0u (52))_ - Microsoft

    I have my groups back.

    I could expand this to include other columns as well, substituting the myint column in my first rule and including it in the second.

    Setup Scripts

    Here is the code to set this up:

    CREATE TABLE MyTestMask
    ( myid INT
    , Mychar VARCHAR(10)
    , myint INT
    , mytinyint TINYINT PRIMARY KEY
    )
    GO
    INSERT dbo.MyTestMask ( myid,
        Mychar,
        myint,
        mytinyint
    )
    VALUES
      ( 1, 'Steve', 12345, 1)
    , ( 1, 'Steve', 12345, 2)
    , ( 2, 'Andy', 12345, 3)
    , ( 2, 'Andy', 12345, 4)
    , ( 3, 'Brian', 12345, 5)
    , ( 3, 'Brian', 12345, 6)
    , ( 3, 'Brian', 12345, 7)
    GO

    I’d urge you to give Data Masker a try if you’re looking to ensure compliant, safe data sets for your non-production environments.

    I have other articles on Data Masker if you’re interested.

  • SQL in the City is Live

    You can watch on YouTube now: https://www.youtube.com/watch?v=0qyMutBkZsg

    If you want slides and notifications, register on the Redgate hub.

    We’re recording the sessions and they’ll be available whenever you have time to watch, but join us today. We’re live.

    The keynote is done, with more sessions to come today.