Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912

    Unanswered: Alter Database...for Attach

    Hi gurus

    Just piddling and diddling in dev. Not important (I can achieve my aim by running some ALTER DATABASE statements subsequently but wondering if this would be possible in a single statement): ATTACH a database and change the logical filenames. What is curious is that this code does not error...but nor does it work - the logical names part just seems to be ignored

    Code:
    CREATE DATABASE newdbname
    ON
          (FILENAME    = 'C:\newdbname.mdf', name = oldlogicalname_data, newname = newlogicalname_data)
        , (FILENAME    = 'C:\newdbname.ldf', name = oldlogicalname_log, newname = newlogicalname_log)
    FOR ATTACH
    GO
    Like I say - no big deal. Just curious that the name and newname options are just ignored rather than invalid. I've tried several different combinations. Thunkles?
    Testimonial:
    pootle flump
    ur codings are working excelent.

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Looks like it can not be done in one statement, Pootle. The BOL article for Create Database has no mention of nEWNAME. I even tried to use the NAME parameter for the new name, but that does not work, either. You will just have to type a little longer, and write that second statement. ;-)

  3. #3
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Quote Originally Posted by MCrowley
    Looks like it can not be done in one statement, Pootle. The BOL article for Create Database has no mention of nEWNAME. I even tried to use the NAME parameter for the new name, but that does not work, either.
    That's the weird thing - why not error?

    This errors:
    Code:
    CREATE DATABASE newdbname
    ON
          (FILENAME    = 'C:\newdbname.mdf', flump = 'pootle')
    FOR ATTACH
    GO
    with
    Quote Originally Posted by SQL Server
    Msg 153, Level 15, State 1, Line 3
    Invalid usage of the option flump in the CREATE/ALTER DATABASE statement.
    It is as though ALTER and CREATE are wrappers for a single class or sommat.

    Quote Originally Posted by MCrowley
    You will just have to type a little longer, and write that second statement. ;-)
    Damn you Microshaft!!!1 Damn yooooooooooooooo!
    Testimonial:
    pootle flump
    ur codings are working excelent.

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,800
    Provided Answers: 11
    Quote Originally Posted by pootle flump
    It is as though ALTER and CREATE are wrappers for a single class or sommat.
    I would expect as much. That is more object Oriented, eh?

  5. #5
    Join Date
    Jul 2003
    Location
    San Antonio, TX
    Posts
    3,662
    Oriented alright, on more abstraction of poor programming
    "The data in a record depends on the Key to the record, the Whole Key, and
    nothing but the Key, so help me Codd."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •