remove read only from a SQL Server data base

  • hy

    i have a data base sql Server .

    I wrote a stored procedure or attach my database but it is attached in read only mode how can remove read-only. thank's for help ^^

    this is my stored procedure.

    create procedure attache

    as

    declare @trouvemdf int

    declare @trouveldf int

    if exists (select name from sysdatabases where name='Gestion_Parc')

    print'deja attache'

    else

    begin

    exec xp_fileexist 'C:\Gestion_Parc.mdf',@trouvemdf output

    exec xp_fileexist 'C:\Gestion_Parc_log.ldf',@trouveldf output

    if @trouvemdf=1 and @trouveldf=1

    begin

    exec sp_attach_db 'Gestion_Parc','C:\Gestion_Parc.mdf','C:\Gestion_Parc_log.ldf'

    end

    else

    begin

    print'file introuvable'

    end

  • i try this EXEC sp_dboption 'Gestion_Parc', 'read only', 'FALSE'

    but it causes those error

    Msg 5120, Level 16, State 101, Line 1

    Unable to open the physical file "C: \ Gestion_Parc.mdf". Operating system error 5: "5 (Access is denied.)".

    Msg 5120, Level 16, State 101, Line 1

    Unable to open the physical file "C: \ Gestion_Parc_log.ldf". Operating system error 5: "5 (Access is denied.)".

    Msg 945, Level 14, State 2, Line 1

    The database 'Gestion_Parc' can not be opened because the files are inaccessible, or memory or disk space is insufficient. For more information, see the error log of SQL Server.

    Msg 5120, Level 16, State 101, Line 1

    Unable to open the physical file "C: \ Gestion_Parc.mdf". Operating system error 5: "5 (Access is denied.)".

    Msg 5120, Level 16, State 101, Line 1

    Unable to open the physical file "C: \ Gestion_Parc_log.ldf". Operating system error 5: "5 (Access is denied.)".

    Msg 5069, Level 16, State 1, Line 1

    Failed to ALTER DATABASE.

    Sp_dboption command failed.

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

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