Category: Blog

  • Granting CONTROL on a database–#SQLNewBlogger

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

    I wanted to grant a login the CONTROL permission on a database. This wasn’t a simple as I expected. I had a login (JoeDev) with no user mappings or server roles, and a database (EmptyFileTest) that I wanted to grant them permissions on.

    My first attempt was this:

    GRANT CONTROL on EmptyFileTest to JoeDev

    This didn’t work.

    2018-07-03 11_20_21-SQLQuery3.sql - (local)_SQL2016.master (PLATO_Steve (60))_ - Microsoft SQL Serve

    I’m a sysadmin, so it’s not permissions. Maybe it’s qualification. The database isn’t found as an object, so let’s fix that.

    GRANT CONTROL ON DATABASE::EmptyFileTest TO JoeDev

    Aha, I’m making progress.

    2018-07-03 11_21_22-SQLQuery3.sql - (local)_SQL2016.master (PLATO_Steve (60))_ - Microsoft SQL Serve

    The database is found, but the user isn’t. That implies this is an internal permission in the database that can’t be granted to the login. One more try:

    GRANT CONTROL ON DATABASE::EmptyFileTest TO LOGIN::JoeDev

    Nope.

    2018-07-03 11_24_41-SQLQuery3.sql - (local)_SQL2016.master (PLATO_Steve (60))_ - Microsoft SQL Serve

    Let’s add the user.

    CREATE USER JoeDev FOR LOGIN JoeDev

    Now we’ll try this again.

    GRANT CONTROL ON DATABASE::EmptyFileTest TO JoeDev

    As you can see, the context is the master database. This won’t work.

    2018-07-03 11_26_07-SQLQuery3.sql - (local)_SQL2016.master (PLATO_Steve (60))_ - Microsoft SQL Serve

    Let’s change the context and execute this again. Once I do that, things work.

    2018-07-03 11_27_29-SQLQuery3.sql - (local)_SQL2016.EmptyFileTest (PLATO_Steve (60))_ - Microsoft SQ

    We can see this worked in the database properties for our database, under the Permissions tab.

    2018-07-03 11_28_29-Database Properties - EmptyFileTest

    SQLNewBlogger

    Security and permissions are important. A series of short pieces on different aspects of managing, assigning, or using security will teach you a lot and show that you’re cognizant of the need for security for your databases.

    This took about 10 minutes to write. Note that I’m showing my process of learning and progress, not just writing about what is required. Think about writing your story, not just the information.

  • Flipping Sides in SQL Operations Studio

    I’ve been starting to use SQL Operations Studio (SOS) a bit more. This is a small, lightweight editor that is based on Visual Studio Code. It’s fairly limited, though it’s still in preview. You can download it and give it a try.

    One of the things that I like is a consistent UI when writing code. I often hide the OE in SSMS, but I don’t want code moving left and right when I’m working with it. That can be a little jarring.

    When working in SOS, I usually start with a query, and no blades (panes?) open. My workspace looks like this.

    2018-07-09 20_02_47-● SQLQuery1 - SQL Operations Studio

    If I need to commit to version control, I’ll click that button, but then my code moves. (I’m really not committing this query. It’s just an example.

    2018-07-09 20_04_12-SQLQuery1.sql - SQL Operations Studio

    The process is just a little distracting to me, especially if I make the pane wider to more easily see the Object Explorer or file list. I didn’t like this in Visual Studio Code when writing PoSh or Python, and I don’t like it here.

    Switching Sides

    Someone on Twitter posted a couple neat tricks, one of which was moving the panes to the right side. I know some panes in SOS, like the connection one, are always over there, but you can move the main panes.

    I’m surprised I didn’t see it, but I really never even thought about this being an option. I was just annoyed.  If I’d looked in the View menu, I’d see “Move side bar right”. If I do that, I get this.

    2018-07-09 20_10_49-SQLQuery1.sql - SQL Operations Studio

    I could also fine this in the command palette

    2018-07-09 20_11_25-SQLQuery1.sql - SQL Operations StudioThe other cool trick doesn’t do much in SOS yet, but it works in Visual Studio Code. I’ll show it there.

    If I create a new file, VSCode doesn’t know what I’m doing. About half the time I’m writing Python, but I don’t get any of the intellisense or other features unless I save the file and give it a type.

    The other option, is to click the language name in the lower right corner. In the image, I’ve clicked the “PowerShell” and this opens a list of languages. Type “py” and get Python.

    2018-07-09 20_13_17-Untitled-1 - Visual Studio Code

    Cool tricks. I expect that over time SOS will have more than just the “mssql” is has now. I’d expect MySQL, PL/SQL, and more.

    .

  • A few fun pics from vacation

    A few nice pics from vacation. Posting here as I’ll link from an editorial.

    IMG_20180727_132656

    IMG_20180730_174346

    IMG_20180731_140618

    IMG_20180730_195100

    IMG_20180802_115314

    IMG_20180724_202448

  • Refreshed and Back from Vacation

    It was a nice break to get away from work for a couple weeks. My family and I traveled 2,000+ miles to Glacier National Park. We camped out each night, and managed to get to both Yellowstone (briefly) and Glacier. Obligatory pic below.

    FB_IMG_1533396327208

    For the most part, I was unwired. There were plenty of places were traveled each day where no connectivity was available. My cell phone was mostly used for pictures, with the “No service” text at the top while in most of the national parks.

    Lots of hiking, and some horseback riding. My wife even managed to get me on a horse one day.

    IMG_20180802_113519

    It was nice to get away, and a little strange to arrive back in a place with more concrete and people than trails and wildlife.

    Going through email and quite a few requests that came in over the last two weeks, as well as starting to prep for SQL Saturday Baton Rouge this weekend. Back in the saddle, as they say, very quickly this week.