Forum Discussion

SrikanthD1340's avatar
SrikanthD1340
Copper Contributor
Oct 17, 2024

Need help in restoring table using large .sql data file(4GB)

We have run into a situation where we need to restore the data into a SQL table. We have taken backup of data only using MS SQL Server and the .sql file size is 4 GB. Since we are unable to open this file in SQL server, we are using sqlcmd to execute this file but after restoring 140K records it is throwing some syntax error (Unclosed quotation mark after the character strig 'abc_121223354565 and incorrect syntax near 'abc_121223354565 ). The .sql file has total 240K records in it.

 

Questions:

1. When the backup was provided by SQL server only, why it is throwing syntax error?

2. How to open this large file to fix the syntax error?

 

if option 2 is not possible, how do we split the large file into smaller chunks so we can identify the exact place where the issue is?

 

Thanks,

Srikanth

 

  • olafhelper's avatar
    olafhelper
    Bronze Contributor

    Questions:

    1. When the backup was provided by SQL server only, why it is throwing syntax error?

    2. How to open this large file to fix the syntax error?


    1. Which tool (+version) have you used to generate the SQL script for data?

    2. Use a common text editor, which handle such large files like Notepad++

     

    Next time use better the BCP tool for export & import data, much performanter, see

    bcp utility - SQL Server | Microsoft Learn

    • SrikanthD1340's avatar
      SrikanthD1340
      Copper Contributor

      olafhelper 

       

      Thanks for the responding. Please find below for inline comments.

      1. Which tool (+version) have you used to generate the SQL script for data?

              Below screenshot for your reference.

       

      2. Use a common text editor, which handle such large files like Notepad++

          we tried notepad++ but we are getting below error. Pls let me know if you have any other ideas.

        

       

      • rodgerkong's avatar
        rodgerkong
        Iron Contributor

        SrikanthD1340 

        Did you mean that SSMS has a feature can backup table to a SQL script? Interesting... Could you show the operation step by step?

         

        BTW, 4G+ file can be opened with UtralEdit.