Skip to content

MS SQL

Command

sqlcmd -S localhost -No -U SA -P <password>
DROP DATABASE [database1]
GO

Restore database

Tested: debian 12

Get file names from backup

sqlcmd -S localhost -No -U SA -Q "RESTORE FILELISTONLY FROM DISK = N'/tmp/database1_19970401.bak'"

Restore

sqlcmd -S localhost -No -U SA -Q "RESTORE DATABASE [database1] FROM DISK = N'/tmp/database1_19970401.bak' WITH MOVE 'database1' TO '/var/opt/mssql/data/database1', MOVE 'database1_log' TO '/var/opt/mssql/data/database1_log'"