Category: Blog

  • SQL Clone Works with FILESTREAM

    SQL Clone is an amazing product that virtualizes your data, allowing multiple instances to share a read only image, but still produce writeable databases that look normal to SQL Server. It’s similar to how a container appears to a user, but this uses real SQL Server instances.

    I need to write up a more detailed walkthrough of this, but someone asked the question today about SQL Clone and FILESTREAM and I didn’t see a proper article on the Redgate site, so I decided to run a test and post this.

    Setting up FILESTREAM

    We have some articles at SQLServerCentral on FILESTREAM, but essentially this feature uses a folder on your instance file system to store blog files, instead of putting them in the database. To enable this, you need to do it in Configuration Manager

    2020-08-12 12_30_53-Window

    and in SSMS

    2020-08-12 12_31_19-Window

    You do need to restart the database engine, but then you can create a database that includes a FILESTREAM filegroup.

    CREATE DATABASE [FSTest]
     CONTAINMENT = NONE
     ON  PRIMARY 
    ( NAME = N'FSTest', FILENAME = N'D:\SQLServerData\SQL2017\FSTest.mdf' , SIZE = 8192KB , FILEGROWTH = 65536KB ), 
     FILEGROUP [FSFG] CONTAINS FILESTREAM 
    ( NAME = N'FSData', FILENAME = N'D:\SQLServerData\SQL2017\FSData' )
     LOG ON 
    ( NAME = N'FSTest_log', FILENAME = N'D:\SQLServerData\SQL2017\FSTest_log.ldf' , SIZE = 8192KB , FILEGROWTH = 65536KB )
    GO

    Once this is done, create a table and load some data.

    CREATE TABLE Books
    (   BookKey     INT              IDENTITY(1, 1)
      , BookTitle   VARCHAR(100)
      , FSGIUD      UNIQUEIDENTIFIER ROWGUIDCOL UNIQUE NOT NULL
            DEFAULT NEWID()
      , BookContent VARBINARY(MAX)   FILESTREAM);
    GO
    DECLARE @Document AS VARBINARY(MAX)
     
    -- Load the image data
    SELECT @Document = CAST(bulkcolumn AS VARBINARY(MAX))
          FROM OPENROWSET(
                BULK
                'E:\Documents\Using Local and Hosted Agents for Build with Azure DevOps.docx',
                SINGLE_BLOB ) AS Doc
     INSERT dbo.Books
         (BookTitle, FSGIUD, BookContent)
     VALUES
         ('Using Local and Hosted Agents for Build with Azure DevOps'   -- varchar(100)
        , NEWID() -- uniqueidentifier
        , @Document
         )         
     ;
    GO

    This gives you a database table with some data in SQL Server, in the Books table, and some in this folder, FSData, on your file system.

    2020-08-12 13_54_32-Window

    DO NOT mess with this folder, but the contents here will be included in any backup.

    Now, I showed how to make an image and clone in a previous post, which I’ll do from this database.

    When I get done, I’ll deploy this to another instance. In this case, I was worried about a folder issue on the same instance, but I’ll test that another day.

    Whoops, I need FILESTREAM on the second instance.

    2020-08-12 12_52_32-Window

    I’ll follow the same config steps as above and restart this instance. this time things work.

    2020-08-12 12_52_28-Window

    If I script the table, I see it is  a FILESTREAM enabled table.

    2020-08-12 12_50_47-Window

    That’s it for now, but I’ll get a proper article written for the Redgate Hub.

  • Daily Coping 12 Aug 2020

    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.

    Today’s tip is to send a positive message to someone you can’t be with.

    I don’t see my middle son often. The oldest and youngest live at home still, but the middle one lives in another city and rarely comes home. He’s in the last year of university, he’s introverted, and very self sufficient. He wants to live his life, and I’m not a helicopter parent. I trust him to manage his life and handle things.

    However, I also want to just let him know I’m thinking of him. He studies Japanese on his own, and I keep trying to brush up, so once or twice a week, I’ll just send him a question. Like:

    お元気ですか

    Just a note to let him know I’m thinking of him.

  • The EU New Stars of Data Come Tomorrow

    One of the things I’ve tried to do when SQL Saturdays is ensure there are lots of local speakers, and new speakers. I’ve argued for more new speakers at the PASS Summit, and I’ve been happy to see them add new ones every year. Speak Idol is fantastic, and I’m glad Denny runs this every year.

    Redgate is sponsoring the New Stars of Data, which is a conference online, tomorrow, 14 Aug, 2020. This is an event built for new speakers.

    The schedule is  great, and I’m looking forward to watching some sessions later. The ones that caught my eye

    Register today, and check out the stars of tomorrow, tomorrow..

  • Daily Coping 11 Aug 2020

    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.

    Today’s tip is to donate some unused items, clothes, tech, etc. to a local charity.

    This has been something I’ve done a few times, and in fact, I had a few bicycles that the kids had outgrown in a shed. I tried to donate them recently, but I missed the donation hours, which had been reduced.

    In writing this tip, I loaded those up and drove them down. This allows them to be used by someone else, at a low price (I donate to Goodwill) and this supports that organization’s efforts.

    BTW, I saw a few friends renovating their kitchens or bathrooms. If you are doing this and have nice cabinets that you are just changing, consider donating to Habitat for Humanity. They will do the deconstruction if the cabinets can be resold.