Later I got the following message when I tried to query the user DBs.
An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)
Invalid object name 'master.dbo.spt_values'. (Microsoft SQL Server, Error: 208)
There is one more table that I had dropped which needed to be recreated and that was 'spt_monitor'. Fortunately, I was doing this on in my test environment and did have a backup of the master database. But I still wanted to find out about these tables. So after some quick googling I found some information regarding this tables. I also found out that we can recreate these tables using some scripts that are located in 'Your SQL Server Install Dir/MSSQL/Install' directory. The script is called 'u_tables.sql' and once you use that to create these two tables the error went away. In case the scripts are missing from the directory that I mentioned please send me an email and I will reply back with the scripts.
Things learned today.
- Always have backups of all DBs.
- Never delete without taking backups.
- If you accidentally delete something then do not panic. GoogleMan will come to your rescue.
Thanks Buddy for the post.
ReplyDeleteRegards,
Srini
Tried copying a SQL 2014 DB from one server to another. Got message that "Invalid object name 'sys.spt_values'." Tried running u_Tables.SQL. Got this error--
ReplyDeleteCreating view 'spt_values'.
Msg 208, Level 16, State 1, Procedure spt_values, Line 56
Invalid object name 'sys.spt_values'.
sp_MS_marksystemobject: Invalid object name 'spt_values'
Msg 15151, Level 16, State 1, Line 62
Cannot find the object 'spt_values', because it does not exist or you do not have permission.