Category: Blog

  • DevOps Basics – Ignoring Files in Git

    Another post for me that is simple and hopefully serves as an example for people trying to get blogging as #SQLNewBloggers. This is also a part of a basic series on git and how to use it.

    One of the things you’ll run into at times is the need to keep some scratch files, or extra files, in your Git repository, but not track them. One common type of file for me when working with SQL is a .zip file. I may zip up code to share or copy to a friend (without giving repo access).

    Ignoring files is easy in Git. We just add a .gitignore file. This is a list of files that the git repository will not track or show in status. Essentially, we see them in our file system, but git doesn’t.

    Creating .gitignore

    To create a .gitignore file, the easiest method for me is to just create a text file. I can do it like this:

    2017-10-09 16_36_08-cmd

    This gives me a new file. Certainly VS Code, Sublime, etc. will make this easy as well.  The format is simple, with a list of files and/or patterns to ignore. For example, I’ve got a .zip file in my repo.

    2017-10-09 16_34_24-GitTests

    I don’t want to see this, but I do right now:

    2017-10-09 16_37_31-cmd

    If I want to ignore this file, I’ll enter this in my .gitignore file:

    GitTests.zip

    If I want to ignore all zips, I’ll do this:

    2017-10-09 16_38_09-cmd

    This is a part of my repo, so I need to commit it.

    2017-10-09 16_38_32-cmd

    Now my status is clean.

    2017-10-09 16_39_14-cmd

    Generated .gitignore

    Some applications will generate a .gitignore. For example, my C# project gets this file from Visual Studio.

    2017-10-09 16_40_33-.gitignore — Visual Studio Code

    That’s a subset of files that are often in a VS project, but we don’t want to track in a VCS. Images, archives, executables, etc.

    You can customize this as you need, and it’s easy to just edit the text file and commit the changes.

    Hopefully this helps you understand how to best work with git and keep your repo clean. This also means your  git add –all is easy to use without adding unnecessary files.

  • Prepping for Summit 2017

    It’s about time for the PASS 2017 Summit. The event essentially starts on Monday with pre-cons and the unofficial networking dinner. Be sure you RSVP and come to the dinner if you don’t have plans. The official event is

    Many people are already traveling and packing for the event. I feel a bit behind as I won’t leave until late Monday afternoon and arrive late Monday night. I’m sure I’m not alone, but it seems like everyone’s ready and I’ve still got a day of work Monday.

    Redgate Software has a booth and a few presentations next week on Wednesday. We’d love to chat with you about ways to make database development easier, especially if you’re thinking DevOps. We also have some contests, swag and prizes.

    I’ll be around Tues, Wed, and Friday, and of course, moving from Game Night to the Redgate Party Thursday night. I’ve got other commitments Thursday day, but hope to see lots of you there.

  • Basic FORMATting– #SQLNewBlogger

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

    I saw the addition of FORMAT() to the T-SQL language, but didn’t play with it much. Recently it appeared in some code, and decided to experiment a bit. I had assumed this was mainly for dates, but it’s a general format/culture function that handles numbers as well.

    On the doc’s page, there are the basic description of the parameters, which are NVARCHAR(), so passing in VARCHAR() causes an implicit conversion. It shouldn’t be much, but there are already performance penalties (see Aaron Bertrand’s piece), so don’t add to the overhead.

    One good thing to note is that if you pass in invalid formats or cultures, a NULL is returned. Since the format and culture strings aren’t completely intuitive, this might be a source of issues in your code.

    This is a neat function, relying on CLR formatting rules. That means I can do fun things like:

    DECLARE @i int = 5000;
    
    SELECT FORMAT(@i, N'USD$#');

    Which returns:

    USD$5000

    Or even:

    DECLARE @i INT = 5000
    ;
    SELECT  FORMAT(@i, N'# dahlahs')
    ;
    GO

    Which gives me:

    5000 dahlahs

    There are lots of formats, and certainly lots of nuances to numeric formatting strings. It’s worth reading up if you plan to use this, but again, beware of performance. I’d avoid using this if the data size is large, maybe more than a few hundred rows.

    After all, the database server is a shared resource, and using this CPU to handle simple formatting may not be the best use of your system.

  • All Day DevOps Slides

    The conference will upload the slides to Slide Share at some point, but if you want to get them now, here are the slides from my talk:

    Including Database in DevOps – AllDayDevOps.pptx

    If you  have questions, drop a note at AllDayDevOps.Slack.com in the #modern-infrastructure channel. I’m way0utwest.