I am trying to import a dump file which is in binary format to SQL Server using sqlcmd command. After running the import command, I am getting this error, Msg 2812, Level 16, State 62 I'm suspecting that it is because the file is in binary format. Is there a way to directly import binary dump file to SQL Server? I tried using the -u flag but I'm getting the same error.

Sorry, forgot to mention, I am using SQL Server 2017 on Ubuntu 16.04

Command: sqlcmd -S localhost -d TestDB -U SA -u -i /home/user1/Downloads/myspecialpresentforyou

Error Message: Msg 2812, Level 16, State 62, Server user1, Line 1 Could not find stored procedure 'TAPE'.

  • Please update your question with the actual command you used - See Help me write this query in SQL May 18, 2018 at 9:05
  • Hi, I updated my post.
    – tango ward
    May 18, 2018 at 9:06
  • Post the SQL command(s) that are in your -i input file. The -i parameter _Identifies the file that contains a batch of SQL statements or stored procedures. _ You should also post the create table DDL for the table you're importing into. May 18, 2018 at 9:12
  • Make sure you're using the proper sqlcmd switches - See the SQLCMD documentation. May 18, 2018 at 9:14
  • Show full error message, not start of it only...
    – Akina
    May 18, 2018 at 9:15

1 Answer 1


The problem of tango ward is that he tries to pass full backup filee as a script file to sqlcmd. I understood it as he wrote the error is

Could not find stored procedure 'TAPE'.

The first bytes of a backup file even if it's disk file are 'TAPE':

enter image description here

To make a simplest restore from the bak file without restoring it to another database and moving the files you still can use sqlcmd, but you should pass your file as a backup file location, i.e. use this command:

restore database MyDB from disk = '/home/user1/Downloads/myspecialpresentforyou'

Here is simple example of doing it in sqlcmd:

  • First I launch sqlcmd (without parameters I'll connect to my default instance with win authentication, but you should use your sa user and password as you did)
  • Once launched sqlcmd you'll see 1> it's a prompt to enter your command, now enter there RESTORE...(the whole command, see above) and after entering it (press ENTER) you'll see 2>
  • Now enter GO to send your command

Here is how I restored my database abc from full backup Z:\Anna\backups\default\abc_full.bak

enter image description here

If you restore to another database you should first know logical file names using restore filelistonly and then move the files to new destination.

If it's your case you'd better use SSMS to see these files as sqlcmd output can be combersome if your db has many files.

Here the example in SSMS:

enter image description here

  • Thanks for this. I ran the code stated above but I am getting an error message: Msg 3154, Level 16, State 4, Server user1, Line 1 The backup set holds a backup of a database other than the existing 'TestDB' database. Msg 3013, Level 16, State 1, Server user1, Line 1 RESTORE DATABASE is terminating abnormally.
    – tango ward
    May 18, 2018 at 10:09
  • This means that you already have TestDB database and it's not this database backup. Why do you want to restore it over existing database?
    – sepupic
    May 18, 2018 at 11:58
  • Hi, sorry for late response. The TestDB is empty. I would just like to put this dump file in this empty TestDB to see the structure of it and proceed with data migration to PostgreSQL.
    – tango ward
    May 21, 2018 at 23:48
  • Basically, this dump file is from a client and I am tasked to perform data migration from SQL Server to PostgreSQL.
    – tango ward
    May 22, 2018 at 0:15
  • Sorry, I am reading this page learn.microsoft.com/en-us/sql/linux/… I tried following the procedures on this site, however I am still getting the same error message. Any advice?
    – tango ward
    May 22, 2018 at 1:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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