Sql server операция create file вызвала ошибку операционной системы

I have a database file .mdf from MS SQL EXPRESS in folder:

C:Program FilesMicrosoft SQL ServerMSSQL10.SQLEXPRESSMSSQLDATA

I would like to attach it to MS 2008 R2 (MSSQL10_50.MSSQLSERVER) but using Server Management Studio I receive the following error:

CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file

Do you have any idea how to solve it?

asked Jun 24, 2012 at 15:07

GibboK's user avatar

GibboKGibboK

71.4k140 gold badges430 silver badges656 bronze badges

3

I was able to solve the problem running MS SQL Management Studio as ADMINISTRATOR.

answered Jun 24, 2012 at 15:11

GibboK's user avatar

GibboKGibboK

71.4k140 gold badges430 silver badges656 bronze badges

3

It’s a Windows permissions issue. If you connected to your server using Windows Authentication then that Windows user needs permissions to the file. If you connected to your server using SQL Server authentication then the SQL Server instance account (MSSQL$, e.g. MSSQL$SQLEXPRESS) needs permissions to the file. The other solutions suggesting logging in as an administrator essentially accomplish the same thing (with a bit of a sledgehammer :).

If the database file is in your SQL Server’s data folder then it should have inherited the user rights for the SQL Server account from that folder so the SQL Server authentication should have worked. I would recommend fixing the SQL Server instance’s account’s rights for that folder. If the data file is somewhere else and the SQL Server account does not have permissions then you will likely encounter other problems later. Again, the better solution is to fix the SS account rights. Unless you are always going to log in as administrator…

answered Jan 31, 2013 at 16:56

user2029904's user avatar

user2029904user2029904

5214 silver badges4 bronze badges

6

Start->Run->services.msc->scroll through the list of services until you find SQL Server->right-click->properties->Log On tab:

Then choose Local System Account and check the Allow service to interact with desktop checkbox.

Restart the service.

Services

answered Feb 27, 2019 at 14:12

TiyebM's user avatar

TiyebMTiyebM

2,6643 gold badges40 silver badges65 bronze badges

Giving admin rights or full control to my database install location solved my problem

answered Jul 8, 2015 at 15:03

sidh4work's user avatar

0

Right Click on File mdf and ldf properties -> security ->full permission

RBT's user avatar

RBT

23.7k21 gold badges158 silver badges240 bronze badges

answered Jan 20, 2015 at 18:51

Ehsan Gholami's user avatar

I had the same problem. After several tries, I realized that connecting the sql server with windows authentication resolved the issue.

answered Nov 22, 2012 at 16:27

Lamar's user avatar

LamarLamar

1,7114 gold badges23 silver badges48 bronze badges

2

I was getting similar error.

CREATE FILE encountered operating system error **32**(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file

I used the following command to attach the database:

EXEC sp_attach_single_file_db @dbname = 'SPDB',
@physname = 'D:SPDB.mdf'

answered Jun 1, 2013 at 20:30

Brij's user avatar

BrijBrij

11.4k22 gold badges76 silver badges115 bronze badges

This same problem occurs when the owners of the file have been deleted. When this happens, if you go to the file’s properties, you will see a SID rather than a user name. Take ownership of the file (giving yourself FULL CONTROL). Once that is done you can do whatever you need to do with the file.

I’ve had this work when logging in as the administrator didn’t do the trick.

answered Nov 30, 2012 at 15:00

PseudoToad's user avatar

PseudoToadPseudoToad

1,4941 gold badge16 silver badges34 bronze badges

As other suggested running as administrator will help.

However this only if the windows user is actually an admisnitrator on the machine which sql server runs.

For example when using SSMS from a remote machine it will not help using «run as administartor» if the user is only a administrator on the machine runing SSMS but not on the machine running SQL Server.

answered May 9, 2013 at 19:39

yoel halb's user avatar

yoel halbyoel halb

12.1k3 gold badges56 silver badges52 bronze badges

1.copy your —.MDF,—.LDF files to pate this location
For 2008 server
C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLDATA
2.In sql server 2008 use ATTACH and select same location for add

answered May 23, 2013 at 12:49

pradeep's user avatar

pradeeppradeep

1381 silver badge3 bronze badges

I had this issue on Windows 2003 with SQL 2005. I had to take ownership of the files as my Windows user account and I got the database to attache that way.

You have to right click on the file, select Properties, click OK to get past the information screen, click the Advanced button, select your account from the listing of available accounts or groups, apply that change, and Click OK on the Properties screen. Once you have done all that you will be able to manage the file permissions.

I logged into SSMS with Windows Authentication and I was able to attach the database without error.

Cheers!

answered Jan 4, 2014 at 13:19

IryDBA2791's user avatar

If you are already running as an adminstrator, make sure the user you are using has the proper server roles.

  1. Login as sa (if you can)
  2. Expand the Security folder
  3. Expand the Logins Folder
  4. Right click on the user you would like to use
  5. Select Properties
  6. Select Server Roles
  7. Select all the server roles
  8. Click OK
  9. Restart SSMS
  10. Login with the modified user

answered Apr 24, 2013 at 15:14

jnoreiga's user avatar

jnoreigajnoreiga

2,15819 silver badges26 bronze badges

In my case I have got the error when trying to create a databae on a new drive.
To overcome the problem I created a new folder in that drive and set the user properties Security to full control on it(It may be sufficient to set Modify ).
Conclusion:
SET the Drive/Folder Properties Security for users to «Modify».

answered May 13, 2014 at 4:45

Menahem's user avatar

My solution was slightly more complicated. After verifying the user the service was running as, running MSSMS as local and domain administrator, and checking folder permissions, I was still getting this error. My solution?

Folder ownership was still maintained by local account.

Properties > Security > Advanced > Owner > (domain/local user/group SQL services are running as)

This resolved the issue for me.

answered Jul 15, 2014 at 19:22

xkalibur's user avatar

Opening SSMS as Administrator and running as SQL Auth vs Windows Auth did not work.

What worked was to just change my filename to the same location where the LDF and MDF files are located.

alter database MyDB
add file ( name = N'FileStreamName', 
filename = N'D:SQL DatabasesFileStreamSpace' ) 
to filegroup DocumentFiles;

answered Dec 9, 2014 at 9:54

Cameron Castillo's user avatar

Cameron CastilloCameron Castillo

2,87410 gold badges47 silver badges76 bronze badges

I got this error when restoring a database that was backed up on another server. After a long struggle this is what I did

  1. Enabled Instant File Initialization,

  2. Granted permissions (full control) on the folder to the service account and my own windows account,

  3. Restarted the SQL service.
    Database restored after that.

dur's user avatar

dur

15.4k25 gold badges76 silver badges119 bronze badges

answered Dec 1, 2015 at 15:07

Lucian's user avatar

We faced this issue, when the windowsuser detaching the database and windowsuser attaching the database are different. When the windowsuser detaching the database, tried to attach it, it worked fine without issues.

answered May 12, 2017 at 21:10

Venkataraman R's user avatar

Venkataraman RVenkataraman R

12k2 gold badges30 silver badges56 bronze badges

Here are the steps:

  1. Right click on the .mdf and .ldf file.
  2. Then select properties.
  3. On the security -> advanced -> permission add the user which

RBT's user avatar

RBT

23.7k21 gold badges158 silver badges240 bronze badges

answered Aug 25, 2015 at 6:22

ehsan farahmand's user avatar

copy your --.MDF,--.LDF files to pate this location For 2008 server C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLDATA 2.

In sql server 2008 use ATTACH and select same location for add

The Hungry Dictator's user avatar

answered Aug 21, 2014 at 7:53

Munish Gupta's user avatar

I just decided to create the file in D: instead of C: and everything worked well. windows 7…10 have many issues regarding the sharing and authorization of files and folder..

answered Mar 17, 2018 at 11:10

Sohail's user avatar

In my case, Run as Administrator does not help. I solved the problem by changing the Build-in Account to Local System in Configuration Manager.

answered Nov 3, 2018 at 9:20

NewComer's user avatar

NewComerNewComer

3071 gold badge3 silver badges8 bronze badges

1

Here is what happened in my case.
I was asked to attach files for a database. I was given the file names as follows

  • devdb.mdf and devdb.ldf

I proceeded to attach the files and kept getting the files are in use by another process.

I ran a query against the system view select name, physical_name from sys.master_files; and saw that the exact file names were already in use by another database, thus each time I tried to attach the files, I kept getting the error the files are in use by another process(sql server)

Thus if you are getting such a message, then also query against the system view sys.master_files and see which database may already be using the same name files.
Hereafter you will figure out what to do.

thanks.

answered Dec 11, 2018 at 21:33

sqladmin's user avatar

if you have mount points add the the SQL server service account to volume security accordingly

answered Feb 20, 2019 at 9:58

meto's user avatar

I also face same problem, but i run Sql server run as administrator so now i resolve the error.

answered Oct 12, 2022 at 6:33

Vandit Joshi's user avatar

1

If facing similar issue in SQL Server running on docker container, fix by granting appropriate permissions to volumes.

  1. Login to container as root user

    docker exec -it -u root <container id> bash

  2. Grant appropriate permissions to all volumes path e.g. /var/opt/sqlserver/data

    chmod 777 </var/opt/sqlserver/data>

answered Mar 9 at 9:25

John Edet's user avatar

No need to do all this. Just right click on database files and add permission to everyone. That will work for sure.

Paresh Mayani's user avatar

Paresh Mayani

127k71 gold badges240 silver badges295 bronze badges

answered Mar 13, 2014 at 18:49

shroffakshar's user avatar

2

I’m trying to execute the following script in SQL Server Management Studio:

USE [master]
GO

CREATE DATABASE [test1] ON PRIMARY (
  NAME = N'test1', 
  FILENAME =
    N'C:Program FilesMicrosoft SQL ServerMSSQL10.SQLEXPRESSMSSQLDATAtest1.mdf',
  SIZE = 70656KB , MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB)
LOG ON (
  NAME = N'test1_log',
  FILENAME =
    N'C:Program FilesMicrosoft SQL ServerMSSQL10.SQLEXPRESSMSSQLDATAtest1_log.ldf',
  SIZE = 164672KB , MAXSIZE = 2048GB , FILEGROWTH = 10%)

But I’m getting the error:

Msg 5123, Level 16, State 1, Line 2
CREATE FILE encountered operating system error 5 (Access is denied.)
while attempting to open or create the physical file
‘C:Program FilesMicrosoft SQL ServerMSSQL10.SQLEXPRESSMSSQLDATAtest1.mdf’.

Msg 1802, Level 16, State 4, Line 2
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

Already have all role permissions for my user, any ideas on what’s wrong?

I have a database file .mdf from MS SQL EXPRESS in folder:

C:Program FilesMicrosoft SQL ServerMSSQL10.SQLEXPRESSMSSQLDATA

I would like to attach it to MS 2008 R2 (MSSQL10_50.MSSQLSERVER) but using Server Management Studio I receive the following error:

CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file

Do you have any idea how to solve it?

asked Jun 24, 2012 at 15:07

GibboK's user avatar

GibboKGibboK

70.3k139 gold badges423 silver badges648 bronze badges

3

I was able to solve the problem running MS SQL Management Studio as ADMINISTRATOR.

answered Jun 24, 2012 at 15:11

GibboK's user avatar

GibboKGibboK

70.3k139 gold badges423 silver badges648 bronze badges

3

It’s a Windows permissions issue. If you connected to your server using Windows Authentication then that Windows user needs permissions to the file. If you connected to your server using SQL Server authentication then the SQL Server instance account (MSSQL$, e.g. MSSQL$SQLEXPRESS) needs permissions to the file. The other solutions suggesting logging in as an administrator essentially accomplish the same thing (with a bit of a sledgehammer :).

If the database file is in your SQL Server’s data folder then it should have inherited the user rights for the SQL Server account from that folder so the SQL Server authentication should have worked. I would recommend fixing the SQL Server instance’s account’s rights for that folder. If the data file is somewhere else and the SQL Server account does not have permissions then you will likely encounter other problems later. Again, the better solution is to fix the SS account rights. Unless you are always going to log in as administrator…

answered Jan 31, 2013 at 16:56

user2029904's user avatar

user2029904user2029904

5214 silver badges4 bronze badges

6

Start->Run->services.msc->scroll through the list of services until you find SQL Server->right-click->properties->Log On tab:

Then choose Local System Account and check the Allow service to interact with desktop checkbox.

Restart the service.

Services

answered Feb 27, 2019 at 14:12

TiyebM's user avatar

TiyebMTiyebM

2,6263 gold badges39 silver badges64 bronze badges

Giving admin rights or full control to my database install location solved my problem

answered Jul 8, 2015 at 15:03

sidh4work's user avatar

0

Right Click on File mdf and ldf properties -> security ->full permission

RBT's user avatar

RBT

23k21 gold badges155 silver badges231 bronze badges

answered Jan 20, 2015 at 18:51

Ehsan Gholami's user avatar

I had the same problem. After several tries, I realized that connecting the sql server with windows authentication resolved the issue.

answered Nov 22, 2012 at 16:27

Lamar's user avatar

LamarLamar

1,6094 gold badges23 silver badges48 bronze badges

2

I was getting similar error.

CREATE FILE encountered operating system error **32**(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file

I used the following command to attach the database:

EXEC sp_attach_single_file_db @dbname = 'SPDB',
@physname = 'D:SPDB.mdf'

answered Jun 1, 2013 at 20:30

Brij's user avatar

BrijBrij

11k19 gold badges75 silver badges115 bronze badges

This same problem occurs when the owners of the file have been deleted. When this happens, if you go to the file’s properties, you will see a SID rather than a user name. Take ownership of the file (giving yourself FULL CONTROL). Once that is done you can do whatever you need to do with the file.

I’ve had this work when logging in as the administrator didn’t do the trick.

answered Nov 30, 2012 at 15:00

PseudoToad's user avatar

PseudoToadPseudoToad

1,4841 gold badge16 silver badges34 bronze badges

As other suggested running as administrator will help.

However this only if the windows user is actually an admisnitrator on the machine which sql server runs.

For example when using SSMS from a remote machine it will not help using «run as administartor» if the user is only a administrator on the machine runing SSMS but not on the machine running SQL Server.

answered May 9, 2013 at 19:39

yoel halb's user avatar

yoel halbyoel halb

12k3 gold badges53 silver badges51 bronze badges

1.copy your —.MDF,—.LDF files to pate this location
For 2008 server
C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLDATA
2.In sql server 2008 use ATTACH and select same location for add

answered May 23, 2013 at 12:49

pradeep's user avatar

pradeeppradeep

1381 silver badge3 bronze badges

I had this issue on Windows 2003 with SQL 2005. I had to take ownership of the files as my Windows user account and I got the database to attache that way.

You have to right click on the file, select Properties, click OK to get past the information screen, click the Advanced button, select your account from the listing of available accounts or groups, apply that change, and Click OK on the Properties screen. Once you have done all that you will be able to manage the file permissions.

I logged into SSMS with Windows Authentication and I was able to attach the database without error.

Cheers!

answered Jan 4, 2014 at 13:19

IryDBA2791's user avatar

If you are already running as an adminstrator, make sure the user you are using has the proper server roles.

  1. Login as sa (if you can)
  2. Expand the Security folder
  3. Expand the Logins Folder
  4. Right click on the user you would like to use
  5. Select Properties
  6. Select Server Roles
  7. Select all the server roles
  8. Click OK
  9. Restart SSMS
  10. Login with the modified user

answered Apr 24, 2013 at 15:14

jnoreiga's user avatar

jnoreigajnoreiga

2,14819 silver badges26 bronze badges

In my case I have got the error when trying to create a databae on a new drive.
To overcome the problem I created a new folder in that drive and set the user properties Security to full control on it(It may be sufficient to set Modify ).
Conclusion:
SET the Drive/Folder Properties Security for users to «Modify».

answered May 13, 2014 at 4:45

Menahem's user avatar

My solution was slightly more complicated. After verifying the user the service was running as, running MSSMS as local and domain administrator, and checking folder permissions, I was still getting this error. My solution?

Folder ownership was still maintained by local account.

Properties > Security > Advanced > Owner > (domain/local user/group SQL services are running as)

This resolved the issue for me.

answered Jul 15, 2014 at 19:22

xkalibur's user avatar

Opening SSMS as Administrator and running as SQL Auth vs Windows Auth did not work.

What worked was to just change my filename to the same location where the LDF and MDF files are located.

alter database MyDB
add file ( name = N'FileStreamName', 
filename = N'D:SQL DatabasesFileStreamSpace' ) 
to filegroup DocumentFiles;

answered Dec 9, 2014 at 9:54

Cameron Castillo's user avatar

Cameron CastilloCameron Castillo

2,85410 gold badges46 silver badges73 bronze badges

I got this error when restoring a database that was backed up on another server. After a long struggle this is what I did

  1. Enabled Instant File Initialization,

  2. Granted permissions (full control) on the folder to the service account and my own windows account,

  3. Restarted the SQL service.
    Database restored after that.

dur's user avatar

dur

14.9k24 gold badges80 silver badges117 bronze badges

answered Dec 1, 2015 at 15:07

Lucian's user avatar

We faced this issue, when the windowsuser detaching the database and windowsuser attaching the database are different. When the windowsuser detaching the database, tried to attach it, it worked fine without issues.

answered May 12, 2017 at 21:10

Venkataraman R's user avatar

Venkataraman RVenkataraman R

11.7k2 gold badges26 silver badges49 bronze badges

Here are the steps:

  1. Right click on the .mdf and .ldf file.
  2. Then select properties.
  3. On the security -> advanced -> permission add the user which

RBT's user avatar

RBT

23k21 gold badges155 silver badges231 bronze badges

answered Aug 25, 2015 at 6:22

ehsan farahmand's user avatar

copy your --.MDF,--.LDF files to pate this location For 2008 server C:Program FilesMicrosoft SQL ServerMSSQL10.MSSQLSERVERMSSQLDATA 2.

In sql server 2008 use ATTACH and select same location for add

The Hungry Dictator's user avatar

answered Aug 21, 2014 at 7:53

Munish Gupta's user avatar

I just decided to create the file in D: instead of C: and everything worked well. windows 7…10 have many issues regarding the sharing and authorization of files and folder..

answered Mar 17, 2018 at 11:10

Sohail's user avatar

In my case, Run as Administrator does not help. I solved the problem by changing the Build-in Account to Local System in Configuration Manager.

answered Nov 3, 2018 at 9:20

NewComer's user avatar

NewComerNewComer

3071 gold badge3 silver badges8 bronze badges

1

Here is what happened in my case.
I was asked to attach files for a database. I was given the file names as follows

  • devdb.mdf and devdb.ldf

I proceeded to attach the files and kept getting the files are in use by another process.

I ran a query against the system view select name, physical_name from sys.master_files; and saw that the exact file names were already in use by another database, thus each time I tried to attach the files, I kept getting the error the files are in use by another process(sql server)

Thus if you are getting such a message, then also query against the system view sys.master_files and see which database may already be using the same name files.
Hereafter you will figure out what to do.

thanks.

answered Dec 11, 2018 at 21:33

sqladmin's user avatar

if you have mount points add the the SQL server service account to volume security accordingly

answered Feb 20, 2019 at 9:58

meto's user avatar

I also face same problem, but i run Sql server run as administrator so now i resolve the error.

answered Oct 12, 2022 at 6:33

Vandit Joshi's user avatar

1

No need to do all this. Just right click on database files and add permission to everyone. That will work for sure.

Paresh Mayani's user avatar

Paresh Mayani

127k71 gold badges239 silver badges295 bronze badges

answered Mar 13, 2014 at 18:49

shroffakshar's user avatar

2

  • Remove From My Forums
  • Question

  •  HI ,

     This is a problem I encountered when I had to detach a database file (type .mdf):

     1) I went to the MS SQL Management Server Studi and detached my database file successfully from a connection called Workhorse.

    2) I needed to place the .mdf database file into a zip file in order to put it on a remote server. I did this using Shared Portal.  This was also successful

    3) However when I tried reattaching the database file, I got this error:

    CREATE FILE encountered operating system error 5A(Access denied.) while attempting to open or create the physical file «CProgram FilesMSSQL ServerMSSQLData<databasename>.mdf’

    Q) The database file and log file (ldf) exist in the correct directory so I don’t know what happened. Can any one help?

     Thanks much

    Tonante

Answers

  • I had same issue on Vista machine. I run «SQL Server Express Management Studio» as «Run as administrator» and it worked. Smile

    • Proposed as answer by

      Tuesday, September 1, 2009 8:56 PM

    • Marked as answer by
      Kalman Toth
      Wednesday, May 28, 2014 12:13 AM
  • I had same issue on Vista machine. I run «SQL Server Express Management Studio» as «Run as administrator» and it worked. Smile

    I was running an Enterprise SQL Server on Win 2008 and ‘Run as Administrator’ fixed the error I was getting.

    • Marked as answer by
      Kalman Toth
      Wednesday, May 28, 2014 12:13 AM
  • Rather then giving permissions to EVERYONE, try running the Management Studio
    as Administrator.

    • Proposed as answer by
      Justin Tolchin
      Tuesday, May 7, 2013 6:59 PM
    • Marked as answer by
      Kalman Toth
      Wednesday, May 28, 2014 12:13 AM

Проблема

При попытке подключить базу данных в Autodesk Data Management Server Console появляется следующее сообщение об ошибке:

Image.png


Autodesk Data Management Server Console ГГГГ

При выполнении команды СОЗДАТЬ ФАЙЛ произошла ошибка операционной системы 5 (доступ запрещен). при попытке открыть или создать физический файл «:Program FilesMicrosoft SQL ServerMSSQL13.AUTODESKVAULTMSSQLDataDb_FilesKnowledgeVaultMaster.mdf».

OK

Среда:

Vault Professional Server можно установить на отдельном компьютере от SQL Server.

Причины:

Права не задаются в файлах и папках SQL Server. Для этого может быть несколько причин.

Решение

Если экземпляр AUTODESKVAULT SQL установлен на компьютере, удаленном от Vault Server, следуйте инструкциям в справочной системе.

Настройка Vault для удаленного SQL

Убедитесь, что учетная запись, которая запускает службу AUTODESKVAULT SQL, имеет разрешение Полный доступ, находится в папке данных SQL и ее содержимом.
Определение учетной записи службы SQL

  1. Нажмите клавиши Windows Start Key + R.
  2. Запустится апплет «Run».

Изображение, добавленное пользователем

  1. Введите Services.msc.
  2. Нажмите «ОК».
  3. Найдите службу SQL Server (AUTODESKVAULT).

Изображение, добавленное пользователем

  1. Учетная запись службы — это значение, отображаемое в поле «Вход в систему как».
  2. Убедитесь, что в учетной записи службы имеется полный доступ к папке данных SQL и ко всем содержащимся в ней файлам.

Изображение, добавленное пользователем

  1. Учетная запись службы — это значение, отображаемое в поле «Вход в систему как».
  2. Убедитесь, что в учетной записи службы имеется полный доступ к папке данных SQL и ко всем содержащимся в ней файлам.

Изображение, добавленное пользователем

См. также:

  • Сообщение «При выполнении команды CREATE FILE произошла ошибка операционной системы 2 (системе не удалось найти указанный файл)…» при попытке подключения базы данных к SQL Server
  • Сообщение «При выполнении команды СОЗДАТЬ ФАЙЛ произошла ошибка операционной системы 32 (процесс не может получить доступ к файлу, так как он используется другим процессом)…» при подключении хранилища с помощью консоли ADMS

Программы

Vault Basic, Vault Professional, Vault Workgroup

Ошибка на ровном месте (но найти решение оказалось очень трудоемким), поэтому решил выложить, авось кому пригодится

Добрый день, коллеги!

В общем, история такая. Есть БД на 1С 8.2, которую я переношу на 1С 8.3, вроде процесс идет. Все ниже перечисленное (алиас БД и прочее — вымышленное или тестовое 🙂

Давеча решил восстановить БД из архива, все просто, но вот застрял на пару дней. У меня была одна тестовая база, и я решил накатить архив на нее. Архив восстановился без проблем, я поработал, потом решил забрать БД домой и проработать детали дома (благо февральские праздники, вообще не представляю, что делать в длинные праздники). Поработал дома, прихожу в офис, копирую БД и делаю «Присоединить» и опля — ошибка:

Сразу подумал на права, назначил все права, полный доступ, Unlocker не помог. Русский сегмент интернета тоже, там сходились на мысли, мол «дай права и все», «проверь под какой учеткой запускается сервисы sql», короче ничего дельного. Пришолось гуглить на забугорных сайтах и вот добрый человек из «клятой» нами «пиндосии» дал норм совет, который я и выкладываю (если кто сможет объяснить лучше я только рад)

1. Проблема была в системной базе TempDB, а имеено типа в ней уже лежит инфа о том, что БД, которую я пытаюсь присоединить уже «присоединена», хотя в списке БД в дереве «Обозревателя объектов» этой БД нет, поэтому попытка «Присоединить» заканчивается fatal error OS код ошибка (32 ). Надо как-то обновить инфу в этомй системной базе.

2. Для начало надо было убедиться в что ошибка именно в этом, скачиваем программу Process Explorer

3. Запускаем

4. На панели инструментов «Find» ищем какие процессы «глумятся» над нашим mdf файлом

5. Видим такую картину

6. Как видно, кроме sqlserver никакого

7. Далее запускаем из командной консоли следующую последовательность команд

1. Старт SQL Server с параметрами “Net Start MSSQL$SQL2014 /mSQLCMD /f /T3608” 
2. Старт SQLCMD с параметрами «SQLCMD –S(local)SQL2014» 
3. Выполним скрипт T-SQL

USE master;
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = tempdev, FILENAME = 'C:Program FilesMicrosoft SQL ServerMSSQL12.SQL2014MSSQLDATA	empdb.mdf');
GO
ALTER DATABASE tempdb
MODIFY FILE (NAME = templog, FILENAME = 'C:Program FilesMicrosoft SQL ServerMSSQL12.SQL2014MSSQLDATA	empdb.ldf');
GO

4. Стоиим SQL командой “net stop MSSQL$SQL2014

5. Старт SQL.в норм режиме (без параметров)

Возможно, у вас пути выглядят по-другому, у меня все стандартно на C установлена.

И вуаля БД присоединяется без проблем, и можно дальше колдовать над ней. Спасибо аглицким доброжелателям, нехай зря мы их «поливаем» дер….мом.

P.S. может, излишне эмоционально, но реально это помогло, а то все 4 дня магичекого колдовства дома над базой, и бац — на работе не мог обновиться (дело не в коде и сравнить/объединить cf файл, а именно сама инфа, которую не выгрузишь в dt файл (нет, можно выгрузить, но только лет через 100 выгрузится база размером 600 ГБ), так что гоняю базу через sql).

Ну и всех женщин с наступающим международным женским днем!

grillz

0 / 0 / 0

Регистрация: 09.10.2012

Сообщений: 27

1

Ошибка при создании базы

30.01.2013, 13:47. Показов 12465. Ответов 2

Метки нет (Все метки)


Сообщение 1802, уровень 16, состояние 4, строка 1
Ошибка операции CREATE DATABASE. Некоторые из перечисленных имен файлов не были созданы. Проверьте связанные ошибки.
Сообщение 5123, уровень 16, состояние 1, строка 1
Операция CREATE FILE вызвала ошибку операционной системы 5(Отказано в доступе.) при попытке открыть либо создать физический файл «D:Institut_Robu.mdf».
Сам запрос:

MySQL
1
2
3
4
5
create database Institut_
on primary
(name=institute,filename="D:Institut_Robu.mdf")
log on
(name=institute_log,filename="D:Institute_log_.Robu.ldf")

Скрин

Миниатюры

Ошибка при создании базы
 

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь

0

0 / 0 / 0

Регистрация: 09.10.2012

Сообщений: 27

30.01.2013, 22:37

 [ТС]

2

как я разобрался, то нету прав администратора.. хотя непонятно почему. как это решить?

Добавлено через 7 часов 53 минуты
разобрался. закрывайте.

0

asd24

107 / 107 / 5

Регистрация: 28.12.2012

Сообщений: 207

30.01.2013, 22:37

3

Для начала попробуйте выполнить

T-SQL
1
CREATE DATABASE Institut_

Этим вы сможете проверить есть ли у вас права на создание БД
Также вам необходимо глянуть настройки пользователя, под которым работаете.
Security -> Logins -> Выбираете своего пользователя -> ServerRole — sysadmin, public

1

Я
   AzamaT90

15.01.18 — 08:11

Всем привет. Не могу запустить задачу «проверка целостности база данных», должен срабатывать через агент, но даже в ручную не запускается. Выдает ошибку:

Сбой выполнения запроса «DBCC CHECKDB(N’alpha’)  WITH NO_INFOMSGS

» со следующей ошибкой: «Невозможно создать моментальный снимок базы данных из-за ошибки ее запуска.

Операция CREATE FILE вызвала ошибку операционной системы 5(Отказано в доступе.) при попытке открыть либо создать физический файл «G:SQLalpha.mdf:MSSQL_DBCC6».

Не удалось создать моментальный снимок базы данных для проверки в сети. Причина содержится либо в предыдущем сообщении об ошибке, либо в том, что один из используемых дисковых томов не поддерживает разреженные файлы или дополнительные потоки. Производится попытка получить монопольный доступ для запуска проверки вне сети.

Базу данных нельзя заблокировать монопольно для выполнения операции.

Инструкция проверки отменена. База данных не может быть проверена, так как не удалось создать ее моментальный снимок, и база данных или таблица не может быть заблокирована. Более подробно о том, когда возникает данная ситуация и какие существуют обходные пути, см. электронную документацию. См. также предыдущие сообщения об ошибках.». Возможные причины сбоя: проблемы с этим запросом, свойство «ResultSet» установлено неправильно, параметры установлены неправильно или соединение было установлено неправильно.

Права на папку дал все пользователем sql, место на HDD на половину занято.

   DrZombi

1 — 15.01.18 — 08:38

(0) Сервер скуля не может писать, вроде нормально описал, сам скуль. Вопрос то в чем, как правильно читать написанное? :)

   DrZombi

2 — 15.01.18 — 08:42

+ Проверь право доступа к файлику скуля

+ проверь место на скуль сервере.

+ Есть замечательный ресурс по работе с эсКуэлем

http://www.sql.ru/forum/991813/prisoedinenie-fayla-bazy-bez-fayla-loga

И даже там пишут, что автор сам виноват, и не читает логи и сообщения :)

   rs_trade

3 — 15.01.18 — 08:42

(0) вопрос то в чем? в ошибке все же расписано что и почему.

   MrCoffin

4 — 15.01.18 — 10:08

(0) «Права на папку дал все пользователем sql, место на HDD на половину занято.»

Надо не всем, а пользователю из-под которого запущен скуль.

«На половину» — на половину лаптя? В цифрах давай, хотя, подозреваю, что проблема только в пользователе.

  

AzamaT90

5 — 15.01.18 — 10:09

Ошибка была в свойствах файлах баз. Была помечена только чтения. Всем спасибо.

Компьютеры — это как велосипед. Только для нашего сознания. Стив Джобс

ВНИМАНИЕ! Если вы потеряли окно ввода сообщения, нажмите Ctrl-F5 или Ctrl-R или кнопку «Обновить» в браузере.

Тема не обновлялась длительное время, и была помечена как архивная. Добавление сообщений невозможно.
Но вы можете создать новую ветку и вам обязательно ответят!
Каждый час на Волшебном форуме бывает более 2000 человек.

  • Remove From My Forums
  • Question

  •  HI ,

     This is a problem I encountered when I had to detach a database file (type .mdf):

     1) I went to the MS SQL Management Server Studi and detached my database file successfully from a connection called Workhorse.

    2) I needed to place the .mdf database file into a zip file in order to put it on a remote server. I did this using Shared Portal.  This was also successful

    3) However when I tried reattaching the database file, I got this error:

    CREATE FILE encountered operating system error 5A(Access denied.) while attempting to open or create the physical file «CProgram FilesMSSQL ServerMSSQLData<databasename>.mdf’

    Q) The database file and log file (ldf) exist in the correct directory so I don’t know what happened. Can any one help?

     Thanks much

    Tonante

Answers

  • I had same issue on Vista machine. I run «SQL Server Express Management Studio» as «Run as administrator» and it worked. Smile

    • Proposed as answer by

      Tuesday, September 1, 2009 8:56 PM

    • Marked as answer by
      Kalman Toth
      Wednesday, May 28, 2014 12:13 AM

  • I had same issue on Vista machine. I run «SQL Server Express Management Studio» as «Run as administrator» and it worked. Smile

    I was running an Enterprise SQL Server on Win 2008 and ‘Run as Administrator’ fixed the error I was getting.

    • Marked as answer by
      Kalman Toth
      Wednesday, May 28, 2014 12:13 AM

  • Rather then giving permissions to EVERYONE, try running the Management Studio
    as Administrator.

    • Proposed as answer by
      Justin Tolchin
      Tuesday, May 7, 2013 6:59 PM
    • Marked as answer by
      Kalman Toth
      Wednesday, May 28, 2014 12:13 AM

(I reviewed the comments from this post, but I was not able to resolve my issue).

I am trying to attach a mdf file that I placed in other drive, and I got this error:

enter image description here

I am aware of the permission issue of the folder that I am pointing the file (to attach).

I gave the full control on that folder for both myself and SQL Server account (NT ServiceMSSQL$TEST1).

enter image description here
enter image description here

I am not sure this extra screenshot would help:

enter image description here

What can I do to fix this?

Понравилась статья? Поделить с друзьями:
  • Sql server обнаружена ошибка деление на ноль
  • Sql server код ошибки 0x80004005
  • Sql server management studio ошибка установки
  • Sql server management studio ошибка операционной системы
  • Sql server management studio журнал ошибок