Category: Blog

  • The End of the Month

    This is the last workday for me this month. I’m off to Hawaii for a break, so only coping tips for the next week.

    Aloha.

  • Daily Coping 24 Aug 2022

    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 be kind online. Share positive and supportive comments.

    “Are you a better version of yourself online?”

    I had someone ask this question a few years ago and it struck me as something I should pay attention to often. When I post something, is it something I’d say face to face? Is it something that I might be embarrassed about with my kids or my Mom? Am I improving my reputation with friends or strangers or making it worse?

    All things I think about. Since then, I try to mentally behave and be a better person online. I might lightly joke, troll, or pick on friends, but I do make an effort to be positive and supportive.

  • Daily Coping 23 Aug 2022

    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 notice if someone annoys you, be kind. Imagine how they may be feeling.

    I had the chance to chat with an acquaintance recently at a social event. They were dismayed at the state of the world (politics, finance, and more), as well as how annoying various things in their life had been. I found myself a little annoyed by all the negativity.

    However, I’d been thinking about this tip, not specifically, but in general across the last few years. I’ve made an effort to try and understand and empathize with other points of view. My goal is not to argue the point, but put myself in someone’s shoes to better appreciate their reaction.

    In this case, I could understand why certain things bothered this person, or why they were negative about things in life. It isn’t the reaction I usually have, nor to I ascribe the same level of importance that this person did. Of course, I wasn’t in the situation, so maybe I’d act similarly at times.

    I let their complaints wash over me, and listened, letting them complain. I also thought a bit about how I’d hope I would react differently, find a way to change things or get beyond them rather than just complaining.

  • Import a CSV with a Header Row using BCP–#SQLNewBlogger

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

    I was demoing something recently and needed to show someone how to grab some data from a CSV text file. Since this was a task the person needed to do regularly, but with different files, they wanted to ensure this was programmatic from a command line call outside of SQL Server. They knew the basics of bcp, but weren’t sure how to deal with a header row.

    This is actually fairly simple as you will see.

    BCP Basics

    I have a simple file that looks like this:

    Time,System Production (Wh)
    08/01/2022,"58875"
    08/02/2022,"61260"
    08/03/2022,"60866"
    08/04/2022,"66395"

    I have a basic table of this structure:

    CREATE TABLE [dbo].[Stage](
         [ProdTime] [varchar](20) NULL,
         [ProdValue] [varchar](100) NULL
    ) ON [PRIMARY]
    GO

    This is just a demo import from this sample file. If I run a basic bcp command, I’d typically run this:

    bcp dbo.stage in export.csv -S Aristotle\SQL2017 -d way0utwest -T -t "," –c

    This runs easily, as you see below:

    2022-08-17 12_56_58-D__Downloads

    However, this is my data:

    2022-08-17 12_56_51-solarloading.sql - ARISTOTLE_SQL2017.way0utwest (ARISTOTLE_Steve (69))_ - Micros

    That’s not right. The first row is a header row, and while I can quickly and easily fix this, it’s better not to have to process this. Easier to fix this on the import.

    To do this, I need to look at the bcp documentation and include a flag. The –F flag is for the first row, which I want to set to 2. If I truncate the table and run this command:

    bcp dbo.stage in export.csv -S Aristotle\SQL2017 -d way0utwest -T -t "," -c -F 2

    I see these results:

    2022-08-17 13_02_04-solarloading.sql - ARISTOTLE_SQL2017.way0utwest (ARISTOTLE_Steve (69))_ - Micros

    No header row. There are still issues with this import, but this solves one problem, which is what the SQL New Blogger post is for.

    SQLNewBlogger

    This is a quick example of a post that is part of my daily work. I was showing a customer this, and I had to mock something up, so I grabbed a little sample data and did that.

    I spent about 15 minutes around other work getting this post written and screenshots taken. You could do this as well and show how you import data in a cleaner fashion.