Tag: sql server

  • Unstructured Data in SQL Server

    Abstract:

    More and more of our data does not fit neatly into a structured, relational model of rows and columns of data. In this session, you will learn about how SQL Server stores unstructured data, with a special emphasis on how to use Filestream, which integrates SQL Server with the NTFS file system by storing varbinary(max) binary large object data as files stored within the file system. You will also learn about the new SQL Server 2012 filetable feature, which builds on Filestream and provides the ability to read, write, and update Filestream objects directly through the file system. This session is designed for DBAs and developers who need to learn how to manage large quantities of unstructured data.

    This covers SQL Server 2008, R2, and 2012. The basic Agenda:

    • What is unstructured data
    • Filestream
    • FileTable

    There are demos that look at how Filestream works and how FileTable can be used in SQL Server 2012.

    Level: 200

    Length: 60 Minutes

    Demo code: UnstructuredData.zip

    Slides: UnstructuredData.ppt

    Related Posts:

    Presentations:

    You can view my speaking schedule here: http://wp.me/P14wgJ-1tV

  • Waiting for SP1

    SQL Server 2012
    Is SQL Server 2012 stable enough for you?

    One of the classic tenets in upgrading Microsoft technology seems to be that it’s safer to wait for Service Pack 1 (SP1) before committing to the next version of any platform. There have been people asking if you will upgrade Windows, wait for Dynamics, and more. Last week I saw a blog from Gethryn Ellis that asked if his readers were waiting for SQL Server 2012 SP1.

    I’ve had times when Service Packs that installed smoothly and essentially had no impact on production systems, and I’ve had times when the installation blue screened my test systems. During the latter times I was extremely glad I’d decided to test the SP and not blindly install it on a production system. That is one of the things that worries me about cloud computing. I need to be sure that patches work on my systems.

    This Friday, however, I wanted to take the temperature of the community regarding the latest version of SQL Server. I am not wondering if you are upgrading, or if you have plans to upgrade to SQL Server 2012. Instead, I wanted to ask you this:

    Do you feel SQL Server 2012 RTM is stable enough to install on your production servers?

    I assume you’ll test it, but assuming it works with your application, assuming that cost is not an issue, is the codebase stable enough for you?

    I don’t have any plans to upgrade SQLServerCentral anytime soon. We upgraded last year and not many of the new features will actually make a difference to our application. Licensing is also an issue as we run Standard Edition, and the cost to move to Enterprise Edition s prohibitive. As much as I’d like to implement AlwaysOn in production, it will have to be limited to test systems for me.

    However if cost weren’t an issue, and resources were available, I’d upgrade. I think SQL Server has been getting more and more solid with every release, and I think SQL Server 2012 is as stable as any of the other recent releases. Let us know today if you feel the same way.

    Steve Jones


    The Voice of the DBA Podcasts

    We publish three versions of the podcast each day for you to enjoy.

  • Ownership Chains in SQL Server

    Someone asked the question recently about allowing a user to run a process,but not execute the individual pieces of the process. I replied that ownership chains allow this, and then explained things. Here’s a short example of that.

    Let’s suppose I have a process that removes data from a table and then reloads it. Perhaps it’s a report, perhaps it’s a static look at inventory, it doesn’t matter. Can I allow a normal user to execute the entire process, but not the clear or load pieces?

    I can, and here’s how.

    Suppose I have a clear procedure:

    CREATE PROCEDURE dbo.spClear
    AS
    BEGIN
       select 'Clear'
    END
    go

    For the sake of this example, I don’t have any work here, but the "SELECTClear"’” could be replaced by a TRUNCATE TABLE or other statement.

    By default in SQL Server, I don’t have rights to execute procedures that I haven’t created. In this case, assume a db_owner created this procedure, so a normal user, Joe, would not be able to execute it. In fact, if I log in as Joe and run this, I get:

    SETUSER 'Joe' 
    go
    -- Fails
    EXEC spClear
    go
    

    Msg 229, Level 14, State 5, Procedure spClear, Line 1

    The EXECUTE permission was denied on the object ‘spClear’, database ‘db1’, schema ‘dbo’.

     

    That’s expected, and it’s good.

    Let’s also create a load procedure, as the db_owner.

    CREATE PROCEDURE dbo.spLoad
    as
    BEGIN
       select 'Load'
    END
    go

    Now to manage the process, let’s create a wrapper stored procedure that calls these. For the sake of tracking what’s happening, I have a few statements in there.

    CREATE PROCEDURE dbo.spRefresh
    AS
    BEGIN
       select 'Refresh start'
       EXEC spClear
       EXEC spLoad
       SELECT 'Refresh End'
    END
    go

    If I were to call this process, this is what I’d expect from the call stack:

    • a call spRefresh
    • a result set returning “Refresh Start’”
    • a call to spClear
    • a result set returning “Clear”
    • return to spRefresh
    • a call to spLoad
    • a result set returning “Load”
    • a return to spRefresh
    • a result set returning “Refresh End”
    • end of spRefresh

    Obviously I could have actual delete or truncates in the clear procedure and then some insert in the load procedure. If I attempt to run this as Joe, I get:

    Msg 229, Level 14, State 5, Procedure spRefresh, Line 1

    The EXECUTE permission was denied on the object ‘spRefresh’, database ‘db1’, schema ‘dbo’.

    Expected, because I haven’t granted Joe rights. Let’s do that and execute the procedure:

    GRANT EXECUTE ON dbo.spRefresh TO Joe
    go
    SETUSER 'Joe' 
    GO
    EXEC spRefresh

    I get what I expected for results:

    ownership_a

    I have rights to execute spRefresh. Since the same owner exists for all three objects, dbo in this case, I have a chain that permissions are not checked for spLoad and spClear. I can execute them in the context of spRefresh.

    What about separately?

    EXEC spLoad

    gets me:

    Msg 229, Level 14, State 5, Procedure spLoad, Line 1

    The EXECUTE permission was denied on the object ‘spLoad’, database ‘db1’, schema ‘dbo’.

    and

    EXEC spClear

    gets me

    Msg 229, Level 14, State 5, Procedure spClear, Line 1

    The EXECUTE permission was denied on the object ‘spClear’, database ‘db1’, schema ‘dbo’.

    A nice way to allow someone to execute a group of processes without allowing them to execute any individual one.

  • T-SQL Tuesday #28 – Jack of all Trades, Master of None

    tsqltuesdayIt’s that time of the month again, T-SQL Tuesday Tuesday. This month Argenis Fernandez, MCM, and big round SQL teddy-bear is hosting. His topic is Jack of All Trades, Master of None.

    The second Tuesday of every month is when the blog party takes off. If you want to participate, read Argenis’ post and write your own entry. If you want to host, contact Adam Machanic.

    Jack of All Trades, Master of None

    After my third year of college, I went to work at a new hotel in Virginia Beach. I hadn’t had much experience in the restaurant industry, other than cooking one semester at college, so they hired me to be a busboy and room service waiter. I opened the hotel working in the café, but the slow start caused some people to quit. When a waiter didn’t show up one day, I volunteered, got a chance, and moved up in the world. When a bartender didn’t show up one afternoon, I volunteered, and had a new gig for the rest of the summer.

    It’s been a mantra for me for the most part in my career. I like challenges, I like new things, and I’m not afraid to tackle much. The same way I moved up in the restaurant business to new (and better paying) jobs worked in technology. However the “jack of all trades” philosophy hasn’t been just about getting new jobs, but also being better at my main job.

    At more than a few companies, I’ve been happy to fill in for the network person, the sysadmin, the Exchange manager, the developer, doing my best to fix something or improve it. As I’ve been a DBA, I’ve worked on PHP, ASP, HTML, XML, Cisco IOS, configured T-1 lines, changed batteries in UPSes, and more. Those skills have helped me to understand how things are put together, and enabled me to solve more than a few complex problems, in complex architectures, because I could truly see the forest. Even if I didn’t understand how everything worked, I knew how lots of parts were supposed to work, and how they were plugged together.

    Even today in SQL Server, I write about all sorts of topics, and review pieces on all aspects of the SQL Server platform. I don’t know how to configure them all as an expert, but I know a lot about how most of the platform works, even if I don’t know all the details. Sometimes that’s enough to get me by.

    It’s not all perfect, and I don’t think being Jack is better than being a master. There are more jobs for the “Jacks” of the world, but the pay tends to be lower. Masters make more, but have fewer opportunities, and fewer places they might get to live/work at any point in time. There’s a (I think) higher level of satisfaction from being a master in some area of your field, and I can appreciate that. I’ll also say that most of the “masters” I know that are fairly specialized have this innate motivation to learn more about their topic, which bleeds off into other sections of their field, making them knowledgeable in a “Jack” way on other parts of their industry.

    In the end, I think it’s fine to be a Jack or a master, just be true to yourself. Do the things that you enjoy, and if that’s one or the other, you should have a great career.