Error 5170 Cannot Create File
Contents |
Security: you have exceeded the number of activations allowed—and you are cutoff! » Fixing SQL error 5170: Cannot create file ‘C:\[…]\APP_DATA\ASPNETDB_TMP.MDF' because it already exists.inASP.NET The problem I recently had, for the first time, to mdf' because it already exists. change the file path or the file name, and retry the operation. create a brand-new ASP.NET web application that made use of the built-in Membership/Roles functionality,
Cannot Create File Mdf Because It Already Exists.
using the default of SQL Server Express, NOT a full installation of SQL Server. I had previously wrestled with issues
Sql Server Cannot Create File Because It Already Exists
when upgrading an older application using Membership/Roles to ASP.NET 4.0, and blogged about it . However, this issue was specific to a brand-new ASP.NET 4.0 application, albeit with VS 2010 SP1 and SQL Server
Entity Framework Cannot Create File Because It Already Exists
2008 SP1 installed. All was well until I fired up the Web Site Administration tool and clicked the Security tab. I was suddenly greeted with the following error message: There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the create database failed. some file names listed could not be created. check related errors. button below to be redirected to a page where you can choose a new data store. The following message may help in diagnosing the problem: An error occurred during the execution of the SQL file ‘InstallCommon.sql'. The SQL error number is 5170 and the SqlException message is: Cannot create file ‘C:\[Application_PATH\APP_DATA\ASPNETDB_TMP.MDF' because it already exists. Change the file path or the file name, and retry the operation. CREATE DATABASE failed. Some file names listed could not be created. Check related errors. Creating the ASPNETDB_[app GUID] database… I checked the App_Data directory, and, sure enough, the ASPNETDB_TMP.MDF file was there. Googling didn’t turn up much that was specific to my issue. The fix The answer turned out to be simple, and hinted at in the error message: in the Web.config file in the root of your web app, find the roleManager element, and set it to true:
‘%ls' because it already exists. Change the file path or the file name, and retry the operation. Severity level:16. Description:This error message appears when you try to add a file to a database, that already belongs to the database. Consequences:The T-SQL statement can be parsed, but causes the error at runtime. Resolution:Errors of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. The statement cannot be executed this way. The file specification must exist and https://cushen.wordpress.com/2011/04/06/fixing-sql-error-5170-cannot-create-file-c-app_dataaspnetdb_tmp-mdf-because-it-already-exists-in-asp-net/ must be valid. Within a folder there are only unique filenames allowed. Versions:All versions of SQL Server. Example(s):USE master;IF DB_ID (N'MyExample') > 0DROP DATABASE MyExample;GOCREATE DATABASE MyExampleON PRIMARY( NAME = MyExample_Data, FILENAME = ‘E:MyExample_Data.mdf', SIZE = 5, MAXSIZE = 5, FILEGROWTH = 15% )LOG ON( NAME = MyExample_Log, FILENAME = ‘E:MyExample_Data.mdf', SIZE = 5MB, MAXSIZE = 25MB, FILEGROWTH = 5MB )GO Remarks:In http://www.sql-server-performance.com/2007/cannot-create-file-because-it-already-exists/ the above example we try to create a data file and a log file with identical paths and names. This raises the error. ASK A QUESTION Tweet Array Errors No comments yet... Be the first to leave a reply! Leave a Reply Click here to cancel reply. Popular Latest Tags Setting up Transactional Replication in SQL Server 2008 R2. November 30, -0001 Backing Up a SQL Server Database Directly Onto a Remote Server November 30, -0001 Recovering a SQL Server Database from Suspect Mode November 30, -0001 SQL Server T-SQL Tuning - NOT IN and NOT Exists November 30, -0001 SQL Server T-SQL Tuning - Temp Tables, Table Variables and Union November 30, -0001 SQL Server Logical Reads – What do they really tell us? October 4, 2016 Physical Join Operators in SQL Server - Hash Operator September 21, 2016 Physical Join Operators in SQL Server - Merge Operator August 25, 2016 Techniques to Monitor SQL Server memory usage August 12, 2016 Recovering a SQL Server Database from Suspect Mode August 7, 2016 Forum posts... 2008 R2 2012 Agent AlwaysOn Analysis Ser
task failed with this error in the Maintenance Plan log: A database snapshot cannot be created because it failed to start.
Cannot create file 'D:\\Data\\MyDatabase_Data.mdf_MSSQL_DBCC75' because it already exists. http://sqladm.blogspot.com/2015/08/checkdb-error-because-snapshot-file.html Change the file path or the file name, and retry the operation. http://www.sqlservercentral.com/Forums/Topic546032-7-1.aspx The error text indicates that the file exists which is true. Also the text indicates that the file path or name can be changed. This is not true in this case as one can't define the physical database snapshot when running a Check Database Integrity task. This is why it cannot create can't be defined when running DBCC CHECKDB statement. In the SQL Server Errorlog the failure is also logged: 2015-08-16 03:11:19.77 spid42 Error: 5170, Severity: 16, State: 1.
2015-08-16 03:11:19.77 spid42 Cannot create file 'D:\Data\MyDatabase_Data.mdf_MSSQL_DBCC75' because it already exists. Change the file path or the file name, and retry the operation. As the information is similar the failure cannot create file is confirmed on file details. In this case the server had a hard shutdown (ups!!!) which caused the CheckDB failure. To confirm if the database snapshot on the file is still active this statement: SELECT *
FROM [master].[sys].[databases]
WHERE
[databases].[name] = 'MyDatabase' AND
[databases].[source_database_id] IS NOT NULL; The result is empty which is confirmed by the message: (0 row(s) affected) The snapshot file can be inspected on the metadata through PowerShell using the CmdLet Get-Item: Get-Item -LiteralPath 'E:\Data\MyDatabase_Data.mdf_MSSQL_DBCC75' As I found no other reference on this error I preserved the database snapshot file by moving it to another location. Testing the solution is quite simple as I only have to run a CheckDB on the database: DBCC CHECKDB ('MyDatabase'); As planned the run is good: CHECKDB found 0 allocation errors and 0 consistency errors in database 'MyDatabase'.
DBCC execution completed. If DBCC printed error messages, contact your system administrator. Posted by Niels Grove-Rasmussen at 10:20 Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest Labels: CHECKDB, Maintenance Plan, SQL Server No comments: Post a Comment Newer Post Older Post H
Recent PostsRecent Posts Popular TopicsPopular Topics Home Search Members Calendar Who's On Home » SQL Server 7,2000 » Replication » Cannot configure SQL Server Cannot configure SQL Server Rate Topic Display Mode Topic Options Author Message Bo Lausten-ThomsenBo Lausten-Thomsen Posted Monday, August 4, 2008 6:05 AM Forum Newbie Group: General Forum Members Last Login: Friday, August 8, 2014 6:23 AM Points: 6, Visits: 134 Due to updates to a database which was marked for transactional replication, I disabled the server as publisher and distribution. It seamed to work OK, SQL server reported that it was no longer distributor or publisher.When I try to reconfigure the server as distributor I get the following error:SQL Server Enterprise Manager could not configure xxx as the distributor xxx .Error 5170: Cannot create file 'J:\Program Files\Microsoft SQL Server\MSSQL\Data\distribution.ldf' because it already exists.CREATE DATABASE failed. Some files names listed could not be created. Check previous errors.I found out that distribution.ldf is automatic created when the SQL server starts (I have tried to stop SQL Server, remove the file distribution.ldf and then start SQL server again, distribution.ldf is recreated), but there is no distribution.mdf.How do I get rid of distribution.ldf?I also discovered that the table MSReplication_options still exists in the master table, I think it should disappear when you disable replication. Can this table be deleted?I would appreciate any suggestionThanks,Bo Lausten-Thomsen Post #546032 ch.mohinich.mohini Posted Wednesday, August 6, 2008 4:32 AM SSC Rookie Group: General Forum Members Last Login: Tuesday, October 28, 2008 6:48 PM Points: 35, Visits: 174 yes u drop it Post #547376 Bo Lausten-ThomsenBo Lausten-Thomsen Posted Wednesday, August 6, 2008 5:34 AM Forum Newbie Group: General Forum Members Last Login: Friday, August 8, 2014 6:23 AM Points: 6, Visits: 134 Thanks.I droppe