How to set default location of datafiles

  • Hello,

    Can anybody tell me what parameter can i change to tell SQL Server 2005 the other default path of datafiles when a database is created?

    The point is that i have one sharepoint that creates databases automatically and the path where the datafiles are stored is not the path that i do when i create manually one database.

    Regards.

    Happy New Year

    Jorge Mendes;)

  • USE [master]

    GO

    EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultData', REG_SZ, N'D:\MSSQL.1\MSSQL\DATA'

    GO

    EXEC xp_instance_regwrite N'HKEY_LOCAL_MACHINE', N'Software\Microsoft\MSSQLServer\MSSQLServer', N'DefaultLog', REG_SZ, N'D:\MSSQL.1\MSSQL\LOG'

    GO

  • Another way would be go to Server Properties -> database Settings page and change "Database default locations".

    😀

  • Hi,

    The Server Properties -> database Settings page and change "Database default locations" will only change one database files location but after the database as been creataed, am i right?

    The point is that i want to change the default proprieties for any future database that will be created automatically in future.

    Regards.

    Jorge Mendes

    😉

  • Jorge Mendes (1/2/2008)


    Hi,

    The Server Properties -> database Settings page and change "Database default locations" will only change one database files location but after the database as been creataed, am i right?

    The point is that i want to change the default proprieties for any future database that will be created automatically in future.

    Regards.

    Jorge Mendes

    😉

    This setting will affect any new database you create on the server. It has no effect on your existing databases.

    SMS GUI method uses xp_instance_regwrite to change registry setting.

  • Ops...... 😀 Sorry....

    What a stupid question 😛 i think its the begin of a new year that affected my inteligence.........

    Thanks and regards,

    Happy new year for everyone

    Jorge

Viewing 6 posts - 1 through 5 (of 5 total)

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