Restored database missing views, stored procs and foreign keys

房东的猫 提交于 2019-12-02 05:24:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!