select * from foo;
But after re-creating my database using RESTORE, I now have to do this:
select * from myName.foo;
...where myName is either the name of the database or the name of the database owner. That is, it's the name of the database, but I believe it's also the name of the database owner.
How do I go back to being able to just use the table name?
Thanks!Looks like what's happening is that for some reason when the ASPNET user tries to run a query on tables that were created by JoeSmith, it needs to qualify them as
<username>.<tablename
But this never used to be the case, so there must be a way around it.|||FromDatabase Object Owner:
Referencing database objects
When users access an object created by another user, the object should be qualified with the name of the object owner; otherwise, Microsoft® SQL Server? may not know which object to use because there could be many objects of the same name owned by different users. If an object is not qualified with the object owner when it is referenced (for example, my_table instead of owner.my_table), SQL Server looks for an object in the database in the following order:
--Owned by the current user.
--Owned by dbo.
If the object is not found, an error is returned.
I'm not sure what changed after the restore, but something is now different. Those tables must have previously not been owned by JoeSmith, or the user accessing the tables was different.
Terri|||Thanks, Terri. The problem was, in fact, table ownership. Thedatabase owner was correct, but not thetable owner. After changing the ownership of the tables to "dbo", everything works.
No comments:
Post a Comment