问题
I'm trying to create a copy of a database in SQL Management Studio (SQL Server Express) using Backup-Restore. Local to local. When I do it it copies tables and data, but ignores views, stored procedures and foreign keys.
Object Explorer -> write-click "Databases" -> "Restore Database..." -> put in a name -> select a "from" database -> go
This is the script that gets generated:
RESTORE DATABASE [DbName_raw]
FROM DISK = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\Backup\DbName.bak.1'
WITH FILE = 1,
MOVE N'GeoDo' TO N'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\DbName_raw.mdf',
MOVE N'GeoDo_log' TO N'c:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\DbName_raw_1.ldf',
NOUNLOAD, STATS = 10
GO
Database appears in Object Explorer but with views, stored procs ad foreign keys missing. Can't see anything obvious in the settings of the wizard. What am I missing?
回答1:
Backup and restore will transfer anything in that database, even views and procedures. You must be doing wrong something else. Are you looking at the wrong database? Or is the restore failing?
回答2:
This was because of an old backup file. I was under the impression that backing up from a database would just copy what was there currently, but it turns out that the backups come from snapshots taken of the database instead. Those backups did not contain the missing views, stored procedures and foreign keys.
来源:https://stackoverflow.com/questions/9864381/restored-database-missing-views-stored-procs-and-foreign-keys