Category: Blog

  • Hiding Email with a Dynamic Data Masking Function–#SQLNewBlogger

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

    Dynamic Data Masking is a feature that provides some pseudo-security features. This lets you return a portion of data while hiding other portions for unauthorized users. The classic example is preventing someone from seeing PII data if they are a customer service rep or other non-privileged user.

    Note: THIS IS NOT A SECURITY function, though it is somewhat marketed and talked about it this way. I say pseudo-security, but be careful here. I have a larger article on why.

    A Scenario

    I have a simple table here. I’ll give you some DDL and DML.

    create table DDMEmailTest
    ( MyID int not null identity(1,1) constraint DDMEmailTestPK primary Key
    , MyName varchar(100)
    , Email varchar(100)
    , Salary int)
    go
    insert DDMEmailTest select 'Steve Jones', 'steve.jones@sqlservercentral.com', 200
    insert DDMEmailTest select 'Bob Jones', 'bob.jones@acme.com', 300

    Now, if I query this as a normal user, I see something like the image below. Note I can read the email address.

    2021-11-18 12_05_41-SQLQuery2.sql - ARISTOTLE_SQL2017.sandbox (ARISTOTLE_Steve (57))_ - Microsoft SQ

    Limiting Access

    I can prevent this from occurring by adding Dynamic Data Masking to the column. This is a column level feature, which doesn’t need activating. It’s in SQL Server 2016+ databases. You add masking with an  ALTER COLUMN like shown below. The email() function is built into SQL Server.

    alter table DDMEmailTest ALTER COLUMN Email ADD MASKED WITH (FUNCTION = 'email()')

    When I now query the data, I see this:

    2021-11-18 12_08_18-SQLQuery2.sql - ARISTOTLE_SQL2017.sandbox (ARISTOTLE_Steve (57))_ - Microsoft SQ

    Users that are not admins, or have been granted the UNMASK permission will get masked data. This mask specifically is the first character and then the XXX@XXXX.com value.

    Use it if this fits your scenario.

    SQLNewBlogger

    I was working with DDM to show something to another person and decided to throw this post together. I’d set up the scenario, so I just had to write. This was about 15 minutes of my day.

    You could do the same thing, but explain how you might use this in your organization.

  • Daily Coping 29 Nov 2021

    I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag.

    Today’s tip is to find a new way to tell someone you appreciate them.

    I have a friend going through a hard time. I really enjoy their company and haven’t seen them since the pandemic hit, but I have chatted a few times. I decided to just send a picture recently, a memory of times together. No words, just a picture.

    I got a pleasant response and a picture back. It was a good way for us to remember the importance of our friendship.

  • A Tesla Flat Tire and Mobile Service

    This is part of a series that covers my experience with a Tesla Model Y.

    Earlier this week my wife and I got in the Model Y to head out to coach volleyball. We left the house and started down our road. I noticed a new icon on the display, right below the gear selector. It looked just like the low tire pressure icon in the BMW.

    I swiped over to check the tires, as usually this is cold weather changing pressure in one tire that might have a very slight leak. In this case, 3 tires showed 37psi and 1 was at 32psi.

    Hmmm, I drove a little further, but was worried. I stopped at the next stop sign and my wife got out to check. She said it was flat, and this time I saw the reading at 25psi. We turned around and crept home.

    We could hear some air leaking, so we grabbed our stuff and jumped in another car. I figured I’d deal with it later.

    UPDATE: The tire was leaking air slowly, about 3-4PSI overnight, so the patch didn’t hold. Another post looks at what I had to do.

    Roadside Service

    When I got to the gym, I had a few minutes, so I opened a flat tire roadside assistance call with Tesla. I figured that the tires must be under warranty, but realized later that was silly. I had to talk with a parent and athlete, so I missed Tesla texting me right back. They pinged me within 2 minutes, and then when I didn’t respond, actually called about 10 minutes later. I couldn’t talk and they didn’t have an estimate for a cost, so I closed the call and said I’d call later.

    When I got home, I looked online and most people noted the tires aren’t under warranty from Tesla, as they wouldn’t be from Toyota, but the tire company might do something. Lots of people seem to look to Discount Tire or a local company, but I didn’t want to mess with things. It seems Tesla is in the $50-100 range from previous reports, so I opened a new service call.

    This time I responded to the text, and the agent had me confirm which tire, the size, and the model of tire. They said no loaners we available, but they could tow it to a shop the next day (or the Tesla service center). Or I could wait two days for mobile service.  We have other cars, so I did the 2 day thing. Plus, I didn’t want to spend a bunch of my day at a tire shop.

    They gave me an $80 estimate for repair or a little under $300 for replacement. I figured we just try and see.

    The Mobile Service Experience

    The next morning I got a text from the tech that said they could come out that day. We arranged for an early afternoon meeting. He texted again when he was about 30 minutes away and then when he pulled up. I walked outside and he had started to jack up the car.

    20211123_135654

    He added some air and then got the tire off and he could see where a hole was in the tire. The hole is right in the left middle channel below, and he thought this could be fixed.

    20211123_135817

    What was neat for me was that the mobile van came equipped to fix things. This is a tire shop on wheels, able to dismount and mount tires on wheels, as well as balance them as needed. He didn’t even turn off his engine, and completed the job in about 20 minutes.

    20211123_135706

    He put the tire up and removed it from the wheel. He talked me through the process, noting that the patch goes on the inside for Tesla, not a plug like some places do. I’ve had tires plugged, so I was surprised.

    20211123_140011

    He was hustling, so I couldn’t get a great picture, but there is an inner liner of foam around the middle of the tire inside. This reduces noise. He removed some, and then added a patch with a plug that pushes through from the inside. It was neat to see, and he then cleaned things up and added back a little foam.0

    20211123_140232

    The tire was remounted, balanced, and dropped on the car. He filled out paperwork on his laptop, measured the wear on all tires, and then set things up. He also told me that if I get winter tires, he could come out and do the tire swap across wheels for about $100-150. I need to check what the local shop might charger, but that might be worth it to me. Especially to not have to drag tires to another place.

    Not the cheapest way to get a tire fixed, but quick and convenient. I was happy to pay $80 instead of the $50 I’ve had a shop charge, or even a no cost repair but losing time traveling and waiting.

    I’m surprised more places don’t do mobile service.

  • Daily Coping 26 Nov 2021

    I started to add a daily coping tip to the SQLServerCentral newsletter and to the Community Circle, which is helping me deal with the issues in the world. I’m adding my responses for each day here. All my coping tips are under this tag.

    Today’s tip is to learn a new skill from a friend or share one of yours with them.

    I tend to be someone that does quite a bit myself. I’ve changed oil, brakes, replaced fence posts, built sheds, wired electrical lights. I tend to use YouTube and forums to learn how to do things, and as long as I’m not placing someone in danger or trying to work in a hurry, I usually see if I can fix things myself. I’ll share a skill I learned recently.

    I have had a tractor for about 15 years. I can grease fittings and fill fluids, but I use a local handyman to do service on the tractor. I don’t want to make mistakes here. In that time, he’s replaced the hoses from the controller to the various lift points on the front loaded. I’ve watched and helped him do that, but had never messed with the hydraulic system.

    A couple weeks ago, I was cutting grass and went to life the loaded higher. Fluid spurted out from some hoses and it wouldn’t life. I finished cutting the small area left and then drove back to the house. I got a stool and looked over the forks (I couldn’t reposition things) and saw that one of the metal hydraulic lines was split. I’ve never worked on these, and never had to deal with the combination of flexible hose and rigid metal pipe.

    It didn’t look too complex, and I called my guy. He says that he couldn’t get out for a few days, but that I should be able to use a couple wrenches and loosen things, but be careful about bending the pipes. I looked online at a few message boards, and they had similar advice, noting that I shouldn’t need to bleed this particular system. I was worried about that.

    I ended up taking apart a bunch of nuts and bolts, getting the pipe loose from the flexible hoses on each side and drove to an auto parts store in town that makes hydraulic hoses. He didn’t have rigid pipe, nor did he have the connectors. Supply chains being what they are. He did recommend a place in the next town.

    I got up at 630a the next day and drove over, getting a flexible hose built. They didn’t have the right compression fitting for rigid. I managed to get back, and then had to re-install the guides, thread the flexible hose over top, since it was thicker, and then then zip-tying the hose down. You can kind of see it here.

    20211108_103513

    I added fluid, ran the engine a bit, went up and down a few times, then rechecked fluid. Things seemed to work, and I learned that working with the hydraulics isn’t that hard, but it is messy. Have lots of rags nearby, wear older clothes, and make sure fittings are tight.