Guest Editorial: In Praise of Templates

  • Comments posted to this topic are about the item Guest Editorial: In Praise of Templates

    Best wishes,
    Phil Factor

  • The supplied templates are also a great self-tuition tool for budding DBAs (and others! like moi for instance).

    I try to set aside some time every session to browse through the supplied templates and 'dissect' a particular example to figure out what it's for and how it does it.

    Had forgotten about the 'parameter filler' - thanks for the reminder!

    Best wishes.

  • One of the annoyances of SSMS 2008 is that Ctrl-Shift-M no longer works.

  • Hmm. Cntrl Shift M. It works on the version of SSMS 2008 I have here, but maybe my version is a bit old (10.0.1600.22 ). I'd be surprised if they took it out as it goes way back. Mind you, they irritated me hugely by taking out the hotkey that flipped between windows in 2005. There is a way of redefining these keys via the registry, but you'd need to be both brave and desperate.

    Best wishes,
    Phil Factor

  • Interesting - I'm on the same version. The other shortcut combis all work ok though. I'd just assumed templates had been forgotten. hmmm...

  • Thanks Phil,

    Templates have been a well-kept-secret from me. I have never used them. But I can see how they could really speed up some of my work. Much appreciated info.

    Andy

  • Thanks Phil. It is a big help.

  • A useful feature I'd forgotten all about, thanks. Now how am i going to remember ctrl-shift-m?

    ---------------------------------------------------------------------

  • just think "Mmmm templates"

  • Andy Lennon (2/6/2009)


    just think "Mmmm templates"

    that'll work! cheers andy.

    ---------------------------------------------------------------------

  • Here is a sample of a customised template. There is a type of service table I use whose basic structure is pretty similar. I just delete the bits I don't need. It is far quicker than doing it by point 'n shoot.

    [font="Courier New"]-- =========================================

    -- Create table template

    -- =========================================

    USE <DATABASE, SYSNAME, MyDatabase>

    GO

    IF OBJECT_ID('<schema_name, sysname, dbo>.<table_name, sysname, sample_table>', 'U') IS NOT NULL

      DROP TABLE <schema_name, SYSNAME, dbo>.<table_name, SYSNAME, sample_table>

    GO

    CREATE TABLE <schema_name, SYSNAME, dbo>.<table_name, SYSNAME, sample_table>

    (

       [<table_name, sysname, sample_table>_id] [int] IDENTITY(1,1) NOT NULL,

       [creator] [varchar](80) NOT NULL CONSTRAINT [DF_<table_name, sysname, sample_table>_creator]  DEFAULT (USER_NAME()),

       [insertiondate] [datetime] NOT NULL CONSTRAINT [DF_<table_name, sysname, sample_table>_insertiondate]  DEFAULT (GETDATE()),

       [terminationdate] [datetime] NULL

        CONSTRAINT PK_<schema_name, SYSNAME, dbo>_<table_name, SYSNAME, sample_table> PRIMARY KEY (<table_name, SYSNAME, sample_table>_id)

    )

    GO

    -- Add description to table object

    EXEC sys.sp_addextendedproperty

       @name=N'MS_Description',

       @value=N'<table_description_value,,Table description here>' ,

       @level0type=N'SCHEMA',

       @level0name=N'<schema_name, sysname, dbo>',

       @level1type=N'TABLE',

       @level1name=N'<table_name, sysname, sample_table>'

    GO

    -- Add description to a specific column

    EXEC sys.sp_addextendedproperty

       @name=N'MS_Description',

       @value=N'primary key for the table' ,

       @level0type=N'SCHEMA',

       @level0name=N'<schema_name, sysname, dbo>',

       @level1type=N'TABLE',

       @level1name=N'<table_name, sysname, sample_table>',

       @level2type=N'COLUMN',

       @level2name=N'<table_name, sysname, sample_table>_id'

    GO

    EXEC sys.sp_addextendedproperty

       @name=N'MS_Description',

       @value=N'Date the record was created (automatic)' ,

       @level0type=N'SCHEMA',

       @level0name=N'<schema_name, sysname, dbo>',

       @level1type=N'TABLE',

       @level1name=N'<table_name, sysname, sample_table>',

       @level2type=N'COLUMN',

       @level2name=N'insertiondate'

    GO

    EXEC sys.sp_addextendedproperty

       @name=N'MS_Description',

       @value=N'Date for the termination of the record' ,

       @level0type=N'SCHEMA',

       @level0name=N'<schema_name, sysname, dbo>',

       @level1type=N'TABLE',

       @level1name=N'<table_name, sysname, sample_table>',

       @level2type=N'COLUMN',

       @level2name=N'Terminationdate'

    GO

    EXEC sys.sp_addextendedproperty

       @name=N'MS_Description',

       @value=N'Creator of the record' ,

       @level0type=N'SCHEMA',

       @level0name=N'<schema_name, sysname, dbo>',

       @level1type=N'TABLE',

       @level1name=N'<table_name, sysname, sample_table>',

       @level2type=N'COLUMN',

       @level2name=N'creator'

    GO

    [/font]

    Best wishes,
    Phil Factor

  • Is it possible that your Ctrl+Shift+M is being caught by another program?

    I had this issue with a similar key sequence where an HP diagnostic (or update manager?) was catching them as a hot key - never made it down into the window that had actual focus.

    I was able to override that sequence in the diagnostic S/W that was catching it.

    Happened on a different machine than the one I'm typing into, so I don't have exact details.

  • JoeA (2/6/2009)


    Is it possible that your Ctrl+Shift+M is being caught by another program?

    I had this issue with a similar key sequence where an HP diagnostic (or update manager?) was catching them as a hot key - never made it down into the window that had actual focus.

    I was able to override that sequence in the diagnostic S/W that was catching it.

    Happened on a different machine than the one I'm typing into, so I don't have exact details.

    was that aimed at me? I'm not having problems with it, just knew I wouldn't remember that combination of keys. Thanks anyway. I''l butt out now so things can get back on topic. 🙂

    ---------------------------------------------------------------------

  • Nope, it was for Mr. Icocks, who said his key combo didn't work in SSMS 2008 🙂

  • JoeA (2/6/2009)Is it possible that your Ctrl+Shift+M is being caught by another program?

    I had this issue with a similar key sequence where an HP diagnostic (or update manager?) was catching them as a hot key - never made it down into the window that had actual focus.

    I was able to override that sequence in the diagnostic S/W that was catching it.

    Happened on a different machine than the one I'm typing into, so I don't have exact details.

    was that aimed at me?

    I believe it was aimed at me - for some reason Ctrl-Shift-M doesn't work for on my SSMS 2008 (though it was fine on 2005).

    Something intercepting it sounds pretty plausible - will investigate.

    Cheers,

    Ian

Viewing 15 posts - 1 through 15 (of 23 total)

You must be logged in to reply to this topic. Login to reply