Tag: Redgate

  • A Quick Trip to Agile West

    Redgate is sponsoring Agile West this year, and the marketing team asked me to give a talk on database DevOps technologies.

    I have a keynote talk, called Don’t Forget the Database, that I’ll be delivering on Wednesday. This covers some of the challenges of why the database is harder than software, but doesn’t need to be. I show some demos of zero downtime deployments as a part of this talk.

    Likely I’ll record the demo and talk over it, as I have seen that technique work well and it keeps me from fumbling around.

    My wife is coming with me. This is a quick Tues-Thur trip for me, and easy. Las Vegas is about an hour flight for me, and I only have a few commitments, so this is a chance for the two of us to see a show or two and get out of town for a short break.

    I’m lucky that some of my business travel allows my wife to come around, and it’s worth the expense to bring her and make the trip more enjoyable. That makes it easy for me to handle the 20-30 trips a year I make.

    If you’re at the show, stop by the Redgate booth or my talk and say hi.

  • Flyway with Multiple Folders

    A customer asked about how they could organize their migration scripts in different ways to manage them and worried about it being complex. I decided to test a few things. This post looks at using multiple folders for scripts.

    Setup

    Flyway is controlled by a number of options. These can be in a configuration file or they can be passed into the command line. I’m lazy, and I like things self-contained, so I tend to drop things into the flyway.conf file and specify this in the command line.

    I’m also lazy about command lines, so I created a fw.cmd file with this in it:

    flyway migrate -configFiles=”./flyway.conf”

    Then I set up a few folders on my system. These were subfolders in a repo called SQL1, SQL2, SQL2. I know, I’m not creative. Here are the folders I set up. SQL1 has 3 scripts, each containing a CREATE TABLE statement. In this case, I am creating Table01, Table03, and Table04.

    2023-05-18 12_28_18-sql1

    I do something similar in SQL2, with table Table02, Table10, and Table11.

    2023-05-18 12_28_22-sql2

    SQL3 gets the 5th and 6th tables.

    2023-05-18 12_28_25-sql3

    I did this to check order of operations, as well as using multiple folders. For reference, each file looks similar to this, with numbers changed:

    2023-05-18 13_04_21-V010__tenthtable.sql - ARISTOTLE.foldertest (ARISTOTLE_Steve (60))_ - Microsoft

    I then edited my flyway.conf file. You can name this differently, you just need to pass the appropriate file to flyway when you execute it. By default, flyway.conf is looked for. I changed the variable for flyway.locations to be a comma separated list. In my case, I entered this:

    flyway.locations=filesystem:sql1, filesystem:sql2, filesystem:sql3

    Make sure you uncomment the # from the line.

    Once this was done, I created an empty database, called foldertest. I then ran my fw command and saw this:

    2023-05-18 12_30_45-cmd

    Success, with all my tables created.

    Flyway is set up to search the locations path and load the files and execute them. You can organize your scripts into different subfolders if you want to, and flyway will sort out the ordering, if you’ve named them correctly.

  • Using Data Masker on Chinese Surnames

    A customer had a question recently on masking Chinese characters. I thought that was interesting, so decided to test this out. This is a short post on using SQL Data Masker to accomplish this task, but I’ll a longer one on the Redgate Product Learning site.

    Setting Up A Table

    The first thing here was to get some test data. I was looking for Chinese names, since that was the request. I found this page on the most popular Chinese surnames. With that in mind, I build a small table and a few insert statements with this code. I only used the names Chén, Yáng, Zhào, Huáng, Zhōu, Wú, and one Western name for the demo

     CREATE TABLE dbo.CustomerFromChina
    ( customerid INT NOT NULL CONSTRAINT CustomerFromChinaPK PRIMARY KEY ,
       customersurname nvarchar(100)
    )
    GO
    INSERT dbo.CustomerFromChina
       (customerid, customersurname)
    VALUES
       (1, N'陈'),
       (2, N'杨'),
       (3, N'赵'),
       (4, N'黄'),
       (5, N'周'),
       (6, N'吴'),
       (7, N'Joe')
    GO

    I ran this and saw the results I needed.

    query results with Chinese surnames

    Creating a New Data Set

    SQL Data Masker ships with a number of masking sets, but you can add your own. There is a process, but essentially you create a text file with the data in it and the udef extension.

    The masking sets are in Program Files below the Redgate folder. This is an administative folder, so you need to have admin rights to make a new file. I did that and opened my file in VSCode, which defaults to UTF-8 format. Since I want to use Chinese characters, I need to use a text file that supports unicode.

    I entered four names into my test file and saved it. You can see the entries here.

    2023-05-26 12_29_02-chinesesurnames.udef - Visual Studio Code

    I made the file name, chinesesurnames.udef. Make sure that this doesn’t have the .txt extension at the end.

    Setting The Masking Set

    I opened SQL Data Masker and created a new masking set. I connected this to my database and then went to the Misc. Setup tab. I didn’t see my set (I had this open), so I clicked “Refresh” at the lower left. This brought the data set into the list view. As you can see, I should have capitalized the file name.

    2023-05-26 12_30_25-chinese(unsaved)_ Data Masker for SQL Server.

    If I clicked “Sample” at the bottom, I see my data:

    2023-05-26 12_31_34-chinese(unsaved)_ Data Masker for SQL Server

    Note that the sample window shows a bunch of rows, but they are repeating the same four values.

    Next, I added a new Substitution rule. I picked the CustomerFromChina table and the ChineseSurname column. I also selected my custom data set. This is noted on the right of the image below.

    2023-05-26 12_32_22-Edit Substitution Rule

    I saved this masking set and I was ready to test.

    Testing

    I first connected to the database and ran the query above in one window. Then I opened a vertical tab set, which moved this window to the right.

    Next, I ran the masking set, which was quick on 7 rows of data. I then opened a new query window on the left side of SSMS and ran the same query  I’d run on the right. You can see the results below:

    2023-05-26 12_36_26-SQLQuery1.sql - ARISTOTLE.sandbox (ARISTOTLE_Steve (57))_ - Microsoft SQL Server

    In the image, the right has the original data. CustomerID 1 is Chén on the right, but on the left, this is now Liú. The others are also changed, with Joe also being masked to Liú.

    This worked.

    You can do the same thing with custom masking sets, in any Unicode format or language.

    SQL Data Masker is a great product for managing a set of update scripts that will remote PII data from a database. It is clunky, but it works well for building and updating a project across time and with a team. Way better than T-SQL scripts.

    Give it a try today.

  • Leveling Up for Sales and Marketing

    I’m heading to Austin today for Redgate’s internal Level Up conference. This is designed to help employees improve their skills in some way. The original ones focused on technology skills, but they have grown to include other business skills. A nice writeup from 2019 is here.

    This has traditionally been in Cambridge, UK, but last year we had an event in Austin. I couldn’t attend because of other commitments, and have actually never been to Level Up. Fortunately for me, there are actually a few events this year:

    • Level Up Sales and Marketing, US – May 2023, Austin
    • Level Up Sales and Marketing, UK – June 2023, Cambridge
    • Level Up Technical, UK – July, Cambridge

    This year, I’ll get to attend the first two, though not likely the third. I’d like to hit the technical talks, but I also have a lot of other trips and travel, so I have to pick and choose.

    I’m not speaking here. I speak a lot, and this is a chance for others to share their knowledge. I have offered to mentor and support others, and I ran a presentations tips and tricks session recently. Actually, I may do that in a few other places and record it.

    Having an internal conference isn’t cheap or easy, but it is a neat way to build bonds in the company and tailor training to what you need. I’ve been asked to speak at a few other companies’ conferences, and I’ve always enjoyed it.