473,394 Members | 1,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Restoring a database to a different server and dealing with table/db object ownerships

When I run:
select * from testtable

I get this error message:

Invalid object name 'testtable'.

However, if I run:

select * from testuser.testtable

It works. I'm logged in as testuser, and testuser is the database
object owner and tableowner. This was a restored database from a
different server in SQL Server 2000. The testuser login was in the
previous database. I created the same login in this new test database
and made it database owner.

I've also tried running: sp_change_users_login 'Update_One',
'testuser', 'testuser'

It completed successfully but I still get:

select * from testtable

Invalid object name 'testtable'.

I've also tried creating a different user and making it database owner
and when I change table object owner to this new user, I still get the
same problem. I need to specify:

select * from newtestuser.testtable

Even though I'm logged in as newtestuser.

I also then tried changing table owner to dbo. This seems to work
logged in as either user, but I want to have the tables owned by the
user not dbo. How can I resolve this?

Any help would be appreciated.

Erin
Jul 20 '05 #1
1 3254
[posted and mailed, please reply in news]

erin (er********@yahoo.com) writes:
When I run:
select * from testtable

I get this error message:

Invalid object name 'testtable'.

However, if I run:

select * from testuser.testtable

It works. I'm logged in as testuser, and testuser is the database
object owner and tableowner. This was a restored database from a
different server in SQL Server 2000. The testuser login was in the
previous database. I created the same login in this new test database
and made it database owner.


A little of terminology confusion here.

login - this is an entity that exists on the server level.
user - this is an entity that exists on database level. A database user
may map to a login, but it does have to be the case.

When you restore a database from another server, you can get unexpected
mappings between users and logins. You can use sp_helpuser to see
what the current mappings are.

If you make a login an owner of a database, that login maps to the
user dbo in the database. So if you are logged in as testuser, and
testuser owns the database, and you try to access a table owned by
the *database user* testuser, you need to access the table with
a two-part name. This is because the database user maps to another
login - or no login at all.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Edwinah63 | last post by:
Hi Gurus, i am having problems with restoring a ms sql database. i have restored the database using veritas to a different location ('g:\datafiles') in no recover mode. when i view the...
4
by: Richard Sherratt | last post by:
I'm trying to rebuild from a meltdown. I'm using disk backup files. I could have sworn that I had SQL Server 2000 SP3 installed on the old machine, but maybe not. With SP3 installed, I get a...
2
by: Raffi | last post by:
I use the --all-databases switch to backup my entire database. Sometimes there's a need to restore individual databases or tables form the backup file. What command should I use for this? ...
20
by: xixi | last post by:
hi, we use db2 udb v8.1 on windows, i am trying to use federated database objects to create wrapper, even though i have update dbm cfg using federated yes, i still get error "the instance for the...
29
by: MP | last post by:
Greets, context: vb6/ado/.mdb/jet 4.0 (no access)/sql beginning learner, first database, planning stages (I think the underlying question here is whether to normalize or not to normalize this...
7
by: Gav | last post by:
If you had a class user with variables id, name, password. How would you save this object or its variable date to a MySQL database? And then if you had a dbase populated with id, name, password and...
3
by: josh.kuo | last post by:
Sorry about the subject, I can't think of a better one. I recently wrote some PHP classes that I think might be of interest to this group. Since I have been reaping the benefits of reading news...
1
by: jliebman | last post by:
All, I recently started at a company that has a number of older MS Access 97 database applications that support production and order fulfillment. There is one database with which I have the...
5
by: Troels Arvin | last post by:
Hello, Every so often, I'm asked to help people recover data from tables that were either dropped or where to much data was DELETEed. The complications related to restoring data are a problem....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.