Category: Blog

  • Quick CSV Import with dbaTools – #SQLNewBlogger

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

    Recently I was searching around for some sample data for a project. I stumbled on a CSV of data from the Internet Movie Database (IMDB). I wanted to quickly import this into a database to play with and query. I decided to use dbaTools since my csv python skills were a little rusty and I thought this would be quick.

    This post looks at how easy this was.

    Disconnected from the Internet

    I had downloaded the CSV before getting on a plane, but once I was ready to import this, I had no access to the Internet. This meant I had no access to looking up commands or documentation. As a result, I decided PowerShell and dbatools would be the easiest way to do this.

    I ran a quick Get-Help command and got the name of the command. Using wildcards, I could see the dbatools result below.

    2021-10-27 20_30_29-cmd - powershell

    I then ran “Get-Help Import-DbaCsv” to get the syntax. Using the results below, I wanted to see how quickly this would run.

    2021-10-27 20_31_16-cmd - powershell

    A Quick Experiment

    With the docs above, I created a database and then entered this command.

    $movie = Import-DbaCsv -SqlInstance localhost -Database IMDB -AutoCreateTable -Path "IMDB-Movie-Data.csv"

    This was my experiment. Just try some values and see what happens here. This ran in less than a second, and from ADS, I could see the data had been imported.

    2021-10-27 20_33_42-● SQLQuery_1 - ._SQL2019.IMDB (Integrated) - Azure Data Studio

    When I checked my variable, I saw that things had just worked with the 1000 rows imported in less than half a second.

    2021-10-27 20_34_30-cmd - powershell

    Success!

    This wasn’t my main task, but using some tools and some past knowledge, I figured out how to accomplish this task quickly and get back to the process of writing SQL code to query the data.

    SQLNewBlogger

    My entire purpose here was to write some queries against this data, but I needed to import the data. Either ADS or SSMS have import wizards, but I’ve had various levels of success at times with them. I didn’t want to work through an ETL process. Once I saw how quick dbatools made this, I decided to write this post, based on the ease of getting something done.

    You could easily duplicate this post, noting why you needed to do an import and how easy this was. You could compare this to SSMS or ADS, or even write about starting to use dbatools for this purpose.

    This took me less than 10 minutes.

  • Daily Coping 1 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 remember I can’t do everything. What are the top three priorities this week?

    For me, we’re starting November, and life gets a little busy. This week I’m aiming to (in no order):

    • Work on studying for DP-900. It’s a personal goal, but work asked me to do this, so I get a 2-fer here, and I can use some work time.
    • Volleyball starts, so this week is evaluating players a bit after their high school seasons, organizing some positions and deciding who goes to which positions this Saturday.
    • Go on a date with my wife. The last couple weeks have been a bit hectic, and we need to take some time together one night this week.
  • Losing Cruise Control in the Tesla

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

    The other day the cruise control in the Tesla stopped. I was moving along a road, heard a beep, and then realized the car was slowing quickly. I have the regenerative braking set to the aggresive mode, and so the car was quickly moving from 40mph towards 0. I pressed the accelerator and didn’t think more of it.

    Then it happened again a day or two later. Then again.

    The third time, I realized each time it had been at night, on a narrow road that has some quick up and down hills. The car has often slowed a bit coming up over the hill, but these times I had been using cruise control to keep the speed steady as I returned home.

    The manual notes that autosteer, which I think includes the cruise capabilities as they act similar, can turn off temporarily. Not what you want in a car trying to get to Level 5 autonomy.

    My suspicion is that this is because the rapidly rising road seems like an obstructed view. Careful drivers probably slow slightly coming up over the rise, and I have if there is a biker or car on the side of the road. However, the human thing is to assume the road is clear, which is should be, and then brake hard if it’s not. Telsa seems more conservative and tries not to get into the place where it brakes in an emergency.

    That’s not a great view, in my opinion. Most cars with adaptive cruise will hold the speed unless there is an obstruction, which shouldn’t be the case with a rising road. I’ve driven cars that did this well, not braking unless a car was actually in front of me.

    I wish there were a “report” button on the display that would let me tag a moment with +/- 2 minutes around it and then later add a note to send to Tesla on how the behavior. I realize this would be a lot of reports, but this is the type of feedback they could use to improve their AI/ML models.

    Actually, I can give feedback, so I’ll try that the next time something weird happens.

    I don’t find this to be a safety issue, as I should be ready to take over, and if the car isn’t sure what to do, then be conservative. I just wish I could let it know that this isn’t a place it needs to be that careful.

  • The First Live SQL Saturday in 2021

    I’m getting ready to board a plane now, heading to Orlando for the first live SQL Saturday in 2021. I’m excited and looking forward to seeing friends that I’ve missed. I hope to meet new people and enjoy the event.

    This is only a live event, so no hybrid broadcast, but I’ll get pictures and video and write up a report next week on how things went.