Extract Part Of A Variable

  • Hi,

    I have a variable that holds a database name:

    set @databasename = '[' + 'databasename' + '].'

     

    I need to extract just the 'databasename' part and not the '[' or the '].' parts.  The 'databasename' could be any length of characters. What is the best way to do this?

     

    Any help would be greatly appreciated.

     

    Thanks in advance for your help.

    www.sqlAssociates.co.uk

  • select replace(replace(@databasename,'].',''),'[','')


    * Noel

  • Thanks Noel, that worked a treat! much appreciated.

    www.sqlAssociates.co.uk

Viewing 3 posts - 1 through 2 (of 2 total)

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