Results 1 to 5 of 5

Thread: Urgent!! - Detaching & Attaching db files

  1. #1
    Join Date
    Oct 2002
    Posts
    123

    Angry Urgent!! - Detaching & Attaching db files

    Hi!
    I am trying to detach & attach db files onto another server (sql 7.0).

    I am using this to detach the db:

    Exec sp_detach_db 'dbname', 'false'
    GO

    Then I am copying files over to the destination server & running:

    EXEC sp_attach_db @dbname = 'dbname',
    @filename1 = 'z:\mssql7\data\dbname_data.mdf',
    @filename2 = 'z:\mssql7\data\dbnamer_log.ldf'
    GO

    Then I am running :
    sp_change_users_login 'auto_fix', 'dbADM'
    go

    sp_change_users_login 'auto_fix', 'dbUSER'
    go


    Everythg looks okay, except that there are 2 users created that do not have any login associated to them. & the weird thing is that the tables are all owned by 1 of these 2 logins. The original logins are also there on the destination db.
    Now, I can't drop & recreate these users, as tables are owned by them...what do I do ? Why are these users not created correctly even though the logins are there on the db?

    Please helppppp!!!!!!!!!

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    You can change table owner with sp_changeobjectowner, then drop user.

  3. #3
    Join Date
    Oct 2002
    Posts
    123
    Hmm, I will try that...

    Thanks!

  4. #4
    Join Date
    Sep 2002
    Posts
    12
    You can also try:
    sp_change_users_login 'Update_One', 'login','user'
    go

  5. #5
    Join Date
    Oct 2002
    Posts
    123
    That worked Pan!
    I had tried sp_change_users_login, but with the autofix option...duh! but thanks!

Posting Permissions

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