Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to Attach a database in SQL Server 2005, and get the following error:

===================================

Illegal characters in path. (mscorlib)

------------------------------
Program Location:

   at System.IO.Path.CheckInvalidPathChars(String path)
   at System.IO.Path.GetFileName(String path)
   at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabaseData.PrimaryFile.PopulateAssociatedFiles(String primaryFilePath)
   at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabaseData.PrimaryFile.PopulatePrimaryFileData(String primaryFilePath)
   at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabaseData.PrimaryFile..ctor(SqlManagementUserControl parent, CDataContainer dc, String fullPath, String databaseOwner, ServerConnection connectionInfo)
   at Microsoft.SqlServer.Management.SqlManagerUI.AttachDatabase.IsSelectedFileValid(BrowseFolder dlg)

The path is "E:\Database\DB_Data.MDF" so it should be fine. I fear data corruption. Any ways to look deeper into the file and see if I can get my data out?

UPDATE: Data is corrupt. Any ways to check individual partitions or get some of the data back? Here is the results from sp_attach_db:

Msg 5120, Level 16, State 5, Line 1
Unable to open the physical file "                           E:\Database\NationalDatabase_Log.LDF". Operating system error 2: "2(The system cannot find the file specified.)".
Msg 5120, Level 16, State 5, Line 1
Unable to open the physical file "                                                                                                                                                Ѐ". Operating system error 2: "2(The system cannot find the file specified.)".
Msg 5120, Level 16, State 5, Line 1
Unable to open the physical file "                                      䔀㨀尀䐀愀琀愀戀愀猀攀尀一愀琀椀漀渀愀氀䐀愀琀愀戀愀猀攀开䐀愀琀愀⸀䴀䐀䘀                                                                                                                                                                                         ". Operating system error 2: "2(The system cannot find the file specified.)".
Msg 1813, Level 16, State 2, Line 1
Could not open new database 'NationalDatabase'. CREATE DATABASE is aborted.

share|improve this question
    
what's the path of the log file? –  Sam Aug 5 '09 at 19:59
    
What happens if you run the sp_attach_db stored procedure directly? –  mrdenny Aug 5 '09 at 20:00
    
@Rob: did you find a solution to the bad characters? i.e. 䔀㨀尀䐀愀琀 –  p.campbell Aug 7 '09 at 20:23
add comment

1 Answer

up vote 2 down vote accepted

Perhaps try to run SQL Server's stored proc to attach the DB:

From MSDN:

EXEC sp_attach_db @dbname = N'MyDatabase', 
    @filename1 = N'E:\Database\DB_Data.MDF', 
    @filename2 = N'E:\Database\DB_Data_log.LDF';
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.