Tag: SQLNewBlogger

  • Deleting a Git Branch–#SQLNewBlogger

    I had someone ask me recently about deleting branches. While I had known how to delete a local branch, I had to look up how to delete a remote one. Documenting these both will hopefully help me remember this.

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

    Deleting Branches

    Most parameters have something do to with the action, and most people might guess a –d is used to delete a branch in Git. The actual syntax for a branch named “Feature123” is:

    git branch –d Feature123

    You can also use a –D, though be aware that –D is the same as –d with the –force option. The –d actually aliases to –delete, so you have three options:

    • -d
    • –delete
    • -D (this will run –-force)

    To delete a remote branch, you can use (with v1.7+)

    git push origin –-delete Feature123

    where origin is the remote name and Feature123 is the branch. This is better than the old syntax, and you ought to keep your git up to date.

    You can see this working for one of my branches below:

    2023-10-11 13_20_00-cmd

    Git docs for branch have more details.

    Use this to clean up branches if your changes are merged and you don’t need to send in any more PRs for this branch.

    SQL New Blogger

    This is a simple thing, but one that I don’t do often, so I wrote this as much to document it for myself as to put this out there as a piece of knowledge. If someone reads this post and asks the question in an interview, it’s likely an easy one for me to give.

    You can do this, help showcase your career knowledge and control the interview. This piece took me about 8 minutes to write. You could do your own version of this topic.

  • Quick Filtering in SSMS–#SQLNewBlogger

    I saw someone limit the databases they see in SSMS, which isn’t something I often do, but I thought this was great.

    A Long List

    This is the list of databases on a demo instance I have. While it’s a lot since I do a lot of testing with customers and colleagues, I see plenty of people will lists of databases longer than this.

    2023-09-18 09_39_38-Window

    I also watch them scroll like I do when trying to find an object in a database.

    However, for demos, this is a lot, so I like to slim things down. I used to have a script to detach all the databases and then attach the ones I need, but that’s time consuming and once in awhile, I need a different database, so that’s an issue.

    I saw the someone filter their list by clicking the filter button in the Object Explorer. This is the funnel button shown here:

    2023-09-18 13_57_35-Window

    Once you click this, a dialog appears that let’s you enter your filter criteria. I’ll use a simple filter of “zero” to limit to those databases in my zerodowntime demo.

    2023-09-18 09_39_25-Window

    Once I click “OK”, I see only those databases listed.

    2023-09-18 09_39_18-Window

    If I want to get everything back, I can click filter again and then delete my criteria, or click “Clear” filter. That gets me the entire list back.

    2023-09-18 09_39_32-Window

    Easy.

    SQLNewBlogger

    This post was something I jotted a note about when I saw someone do this. The note was literally “write about filtering in SSMS object explorer”. I took that and wrote this post in 10 minutes, including time to grab screen shots.

    You could do this as well, showcasing the knowledge that you’re learning to use tools better, which make you more productive. Employers love that.

    Write your own post with more advanced filtering.

  • Creating an Empty Repo in GitHub–#SQLNewBlogger

    I saw someone struggling with getting started with a Visual Studio project and Azure DevOps. They got a conflict, which I’ll show and then get you started with an empty repo.

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

    The Problem with Initialized Repos

    I wrote about this recently with Azure DevOps and empty repos.. If I initialize a repo in GitHub, or any online provider, and try to push up a local repo, it returns an error that I have conflicts.

    I’ve learned that when I want to start a new project, either I create the repo locally and then make an empty one online, or I create it online, clone it, and then start working.

    I try to do the second (create online first), but I don’t always remember.

    Creating an Empty Repo

    In GitHub, if you go to your repositories page, you can see a “New” button on the right.

    2023-08-25 16_56_06-Your Repositories — Mozilla Firefox

    Click this and enter a name, as I’ve done below. BTW, I love the suggested name.

    2023-08-25 16_56_30-New repository — Mozilla Firefox

    If you look at the image above, near the bottom, you can see my mouse pointer.

    DO NOT check this box if you want an empty repo. Don’t add a .gitignore either. You’ll be adding code from your own project, which likely has a gitignore file and might have a repo. If not, just create a readme.md file in your local git repo.

    Don’t add a license file either.

    Pushing My Project

    Now when you create this, you get the details of how to push your repository. If you have never used git, just open a command prompt and paste these lines in one by one and run them.

    2023-08-25 17_00_57-way0utwest_myemtyrepotest — Mozilla Firefox

    That’s it and now you can work and commit in either repo and deal with merges.

    SQLNewBlogger

    This post was easy for me, but I’ve been in the situation where I’ve made this mistake. In this case, I’d written the other post, so I knew what to do here. I spent another 10 minutes getting GitHub set, taking images, and writing this.

    Easy to do, 2 posts from one idea, and showcasing knowledge on another platform. I could do another one with BitBucket or somewhere else, and maybe I will. I have customers that use other platforms.

    Maybe you should do this and showcase your versatility to the next person that wants to interview you. If you want to work with software and Git, show them you know the basics. Or even more.

  • Creating Empty Repos in Azure DevOps–#SQLNewBlogger

    I saw someone struggling with getting started with a Visual Studio project and Azure DevOps. They got a conflict, which I’ll show and then get you started with an empty repo.

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

    The Problem with Initialized Repos

    First, I’ll open VS 2019 and create a new database project. I won’ t walk through that, but once I do, then I can add my project to source control. In the lower right corner, this is an option:

    2023-08-09 12_58_07-Zoomit Zoom Window

    I’ll choose a local repository here. I see plenty of people do this if they don’t want to use GitHub.

    2023-08-09 12_58_34-

    Now, I go to Azure DevOps and create a project. I initialize that project with a Readme, which seems like a good idea. You can see my online repo below:

    2023-08-09 12_56_01-VS DB Project Test - Repos

    When I create this, I get the options to link an existing repo or push up.

    2023-08-09 12_59_54-Database2 - Microsoft Visual Studio

    However, if I try to link my existing local repo, I get an error.

    2023-08-09 13_00_19-Database2 - Microsoft Visual Studio

    Why? I have a commit in the report (initialized with a readme) and commits locally. That’s a conflict.

    Creating an Empty Repo

    The way to avoid this is make an empty repo in Azure DevOps without anything in it. When you see this screen, un check the “add a README”. No matter how much you want to have one, don’t do this.

    2023-08-25 16_35_11-VS DB Project Test - Repos

    Now, you have an empty repo for the remote. You should see this online, with the first line noting this is empty. From here, you can use the second box to push your repo from the command line.

    2023-08-25 16_36_17-Files - Repos

    SQLNewBlogger

    This post was easy for me, but I’ve been in the situation where I’ve made this mistake. It’s annoying, but it’s also confusing as you should be able to make changes in both repos. That’s why we use git.

    You can, but not when both are initialized. You need to clone one from the other.

    This post took me about 15 minutes to create, with a good portion of time spent creating the scenario twice (two repos) and the db project in VS, which is slow. You could do this same thing and show how (and why) you set up a project linked to source control. If you use a couple systems (one at work and one at home) make two posts!