V
V
Viktor Familyevich2019-05-04 14:54:03
Database administration
Viktor Familyevich, 2019-05-04 14:54:03

How to transfer the database with the project?

I created a database at (localdb)\mssqllocaldb and a project that uses it, but when transferring the project to another computer, the database is not transferred, how can I make it transfer?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Tsvetkov, 2019-05-04
@tsklab

Move.bat
@echo off
echo -- Архивирование базы данных
osql -S SDATA -E -i Move.backup.sql -n
echo -- Перенос данных
copy \\SDATA\Data\MSSQL\BACKUP\QBill.move.bak \\SWEB\D$\MSSQL\QBill.move.bak
echo -- Восстановление базы данных
osql -S SWEB  -E -i Move.restore.sql  -n
Move.backup.sql
BACKUP LOG [General] WITH NO_LOG
GO
--
DBCC SHRINKDATABASE ([General])
GO
--
BACKUP DATABASE [General]
  TO DISK = 'D:\MSSQL\BACKUP\QBill.move.bak'
  WITH INIT, NOUNLOAD,  NAME = 'General home backup', NOSKIP, STATS = 5,  NOFORMAT
GO
Move.restore.sql
RESTORE DATABASE [General]
  FROM DISK = 'D:\MSSQL\QBill.move.bak' WITH FILE = 1, NOUNLOAD, STATS = 5, REPLACE,
    MOVE 'General_Log'   TO 'D:\MSSQL\General.log',
    MOVE 'General_Data'  TO 'D:\MSSQL\General.mdf',
    MOVE 'General_Event' TO 'D:\MSSQL\General.ndf'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question