Author: way0utwest

  • Transferring Table Types

    An interesting idea. I saw this question asked after I was playing with table types a bit. “Can you move a table type between schemas?”

    Suppose I had two schemas:

    CREATE SCHEMA OldSchema
    ;
    GO
    CREATE SCHEMA NewSchema
    ;
    GO

    In one of them, I create a table type and a procedure:

    CREATE TYPE OldSchema.MyTable AS TABLE
    ( IDCode INT
    , Location VARCHAR(200)
    )
    ;
    
    CREATE PROCEDURE OldSchema.MyProc 
    AS
     SELECT * FROM dbo.MyLogger
    ;
    

    There’s nothing fancy here. Just two objects created in one schema. I now have the need to move these to the other schema. Perhaps it’s a mistake. Perhaps I have developers working in one schema and I do integration testing in the other schema. In any case, it’s easy to move the proc with the ALTER SCHEMA syntax:

    ALTER SCHEMA NewSchema TRANSFER OldSchema.MyProc
    ;

    I can easily script something to move multiple procs, but if I do this:

    ALTER SCHEMA NewSchema TRANSFER OldSchema.MyTable
    ;

    I get this:

    Msg 15151, Level 16, State 1, Line 1

    Cannot find the object ‘MyTable’, because it does not exist or you do not have permission.

    I know it’s there; I just created it. What’s wrong?

    The problem is that this isn’t an object per se, but a type. As a result, to move a type, I need to use a different syntax:

    ALTER SCHEMA NewSchema TRANSFER type::OldSchema.MyTable
    ;
    GO

    That works fine and the type has moved. The class attribute of the notation is

    CLASS::Schema.Object

    I haven’t found good documentation of this, but there are numerous examples in BOL that show this is how you address various “types” in SQL Server.

  • Rewrite the Coding Rules

    Cryptanalyses
    It’s becoming more important to code securely.

    Security is a problem in technology. Whether it’s technological misconfiguration, social engineering, or brute force attacks, we see a constant stream of headlines about security issues. The situation is not likely to change anytime soon as security isn’t seen as a priority by many companies. If that’s the case, then is there anything that can be done to improve security?

    Security expert Dan Kaminsky says that we need a fundamental change in the way we write code. By rewriting the way that code is developers, rewriting the rules, we can reduce the vulnerabilities in our applications. One theory is that our languages and the coding techniques used are making it entirely too easy for vulnerabilities to creep into code.

    It’s an interesting theory, especially these days when it seems so many of our applications are under attack. I suspect that we have lots of poor habits ingrained in many developers. People are loathe to change and they like to continue working in ways that have worked for them. However the world of security in software changes constantly. What might have made you a very effective and productive developer five years ago might make you a liability today.

    I believe that we need to somehow build new coding methods, but even more importantly I think people that provide sample code and framework need to do so in a way that showcases best practices and good habits from a security perspective. That includes presenters, who should never show security issues, even if it’s for the sake of simplicity. Raise the bar and your audience will come along with you.

    Steve Jones


    The Voice of the DBA Podcasts

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

  • Verify those Backups

    It’s important that you backup your database. The most important thing you can do. However making backups isn’t enough: you need to verify those backups are good.

    A humorous short video from Grant Fritchey (b | t) and RedGate on why:

    Watch the video

    Ideally you verify every backup every day, but that’s not always feasible. At least make sure you’re doing one backup from every database at least once a month.

  • Teammates

    Terry Tate
    Are you like Terry Tate in your office?

    I loved the Terry Tate commercials as a young office worker. They were unveiled at the Super Bowl in 2003, when I was still managing a database team at Peoplesoft, with weekly issues occurring on our production systems. There were times I wished I could hire Terry to try and convince more people they should be working together using the stick instead of the carrot.

    I have known a few people that worked with former atheletes in real life. If you didn’t recognize them from their past, you might never realize they used to play sports for a career. I was reminded of them by this short slide show that imagined various NFL players as office workers. If you can get past the idea of professional athletes attacking your business problems in the same way they play on the field, the piece shows a number of different personalities that you might find in business. I’ve dealt with many of these in the past, with mixed experiences. I certainly haven’t enjoyed working with the “Lawrence Taylors” of the business world.

    This Friday I wanted to make this a fun poll. I thought you might want to describe yourself or your boss with a famous figure:

    Which professional athlete (or other star) displays the type of traits you think would best suit your position?

    It doesn’t have to be an athlete. Pick someone in the arts, music, movies, etc. Just choose someone famous that you think would exemplify the person you want to be perceived as, or would like to grow to be like. Or represents you now if that’s the case.

    For me, I think Lawrence Lessig has a fantastic way of expressing himself in relatively few words, but in a very logical manner. I also appreciate his passion and knowledge on various topics. Some day I hope I can express myself as well as I think he does.

    Steve Jones


    The Voice of the DBA Podcasts

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