SQL Server Developer Center > SQL Server Forums > SQL Server SMO/DMO > Smo Restore.ReadFileList(server) fails
Ask a questionAsk a question
 

QuestionSmo Restore.ReadFileList(server) fails

  • Thursday, November 05, 2009 9:27 PMSPCS Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I am writing a C# application to backup and restore a SQL Server database from one instance to another. I am trying to get the logical names of the data and log files of the database from the .bak file and it fails at the statement "DataTable dt = restore.ReadFileList(server);" with the error {"Incorrect syntax near the keyword 'WITH'.\r\nIncorrect syntax near the keyword 'with'. If this statement is a common table expression or an xmlnamespaces clause, the previous statement must be terminated with a semicolon."}

    Is there anything I have to do before I can use the restore.ReadFileList method ? The logical names of the database files have '.' and '_' in the names, "DBName_data.mdf" and "DBName_log.ldf" . Could it be the reason for this error ?

    I tried restore from SQL Server Express Instance and SQL Server Full Version to SQL Server Full Version. Both of the scenarios resulted in the same error and Restore could not complete.

All Replies

  • Tuesday, November 10, 2009 12:00 PMPapy NormandModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello SPCS,

    Please, could you have a look on this link ?
    http://www.mssqltips.com/tip.asp?tip=1849

    Nearly the end of this article, you have an example of a restore in a different location ( just in case ).

    Don't hesitate to post again if you think you need more help or explanations or if i have not understood your question.

    Have a nice day

    PS : the logical names of files should not have '.' but may have '_'
    I think that for the log file, the logical name is DBName_log ( not DBName_log.ldf which is a physical log file name )
    You should use SSMS to have a look on the different names of log/data files.
    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.
  • Tuesday, November 10, 2009 4:00 PMSPCS Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    I have looked at this link that you have provided earlier.

    The logical names of this database do have '.' Do you think I should rename the logical files to remove '.' and then try to backup and restore the files ?

  • Tuesday, November 10, 2009 10:19 PMPapy NormandModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello SPCS,

    I will do a 2nd test to-morrow morning ( 10 hours from now ) on a SQL Server Dev 2008 ( to see whether there is a difference between 2005 and 2008 ) and i will post the result.

    Have a nice day
    Mark Post as helpful if it provides any help.Otherwise,leave it as it is.