Installing DB

sabzamsabzam Member Posts: 1,149
edited 2009-08-27 in SQL General
Hi Everbody,

Is it possible in some way or another to install a db when having the .mdf file only?

Comments

  • ara3nara3n Member Posts: 9,256
    you need at least the mdf and ndf file.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • LukasNavWalkerLukasNavWalker Member Posts: 6
    Hi,

    You just need the mdf file.

    Create a new Query.

    Attach the Database by SQL Statement with Option Rebuild_Log.

    Lukas
  • ara3nara3n Member Posts: 9,256
    What is the sql script?



    EXEC sp_attach_single_file_db @dbname = 'mee',
    @physname = 'c:\Program Files\Microsoft SQL Server\MSSQL\Data\mee_Data.mdf'



    doesn't work.
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • LukasNavWalkerLukasNavWalker Member Posts: 6
    Sorry, remembered it wrong.

    Create DATABASE [mee]
    ON Filename = 'c:\.....'
    FOR ATTACH_REBUILD_LOG

    Lukas
  • ara3nara3n Member Posts: 9,256
    This option does not work if for multiple data files.....

    And Navision creates two data files.

    Running
    Create DATABASE mee
    ON (NAME='mee',FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\tada_Data.mdf')
    FOR ATTACH_REBUILD_LOG
    

    will give you an error
    Msg 5120, Level 16, State 5, Line 1
    Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\tada_1_Data.ndf". Operating system error 2: "2(The system cannot find the file specified.)".
    File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\tada_Log.ldf" may be incorrect.
    Msg 1813, Level 16, State 2, Line 1
    Could not open new database 'mee'. CREATE DATABASE is aborted.
    
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • krikikriki Member, Moderator Posts: 9,115
    [Topic moved from 'NAV 2009' forum to 'SQL General' forum]
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • LukasNavWalkerLukasNavWalker Member Posts: 6
    Hi,

    I hope you solved the Problem.

    If not, then you should use as second Parameter

    FILEGROUP to attach the NDF-File

    Lukas
  • Peter_Wibeck_[MSFT]Peter_Wibeck_[MSFT] Member, Microsoft Employee Posts: 78
    The solution that I find works is.

    sp_attach_single_file_db @dbname= 'new_Demo Database NAV (6-0)', @physname= 'C:\Program Files (x86)\Microsoft Dynamics NAV\60\Database - Copy\Demo Database NAV (6-0)_Data.mdf'

    You need to ensure that the SQL server user have correct permissions to 'C:\Program Files (x86)\Microsoft Dynamics NAV\60\Database - Copy\' or where you put the db files. I'm using 'NETWORK SERVICE" as the SQL server user account, the NAV will use this account by default when doing demo installation.

    To set permission
    1. Open propertie for the directory.
    2. Click secyrity tab
    3. Click advance
    4. Click edit
    5. If the SQL server user are not pressent press add and pick the user else select the SQL server user and click edit
    6. Change the permission according to the picture
    7. Click OK
    8. Click Ok
    9. Click OK
    10. Click OK
    “This posting is provided "AS IS" with no warranties, and confers no rights.”

    Peter Wibeck
    Software Development Engineer in Test
    Dynamics NAV Server and Installer team
    http://blog.wibeck.org/
Sign In or Register to comment.