views:

39

answers:

2

I have a web application running with a SQL server 2005 DB as back end.I took the db back of the production site and restored in my development machine.Then i tried to query this database using the login "sa".When trying to execute the "select * from Customers" query, i am getting a message like "Invalid object name 'Customers" But when i run "SELECT * FROM [352974_mg4l1].[Customers]", It is returning records. 352974_mg4l1 is a user for this database present when i restored the db backup from production. What i have to do for getting the records using with simple select query which i used initially("select * from Customers" ). I know it is something related to login issue.Can any one tell me how to solve this ?

+2  A: 

The Customers database object is not owned by the dbo schema.

And by referencing Customers as 'sa' you are looking for [dbo].[Customers] ?

I would suggest to:

  • either provide the object's full name
  • either change it's schema

Edit:

To alter the schema of said table try this:

ALTER SCHEMA dbo TRANSFER [352974_mg4l1].Customers;

Reference: http://msdn.microsoft.com/en-us/library/ms173423.aspx

Yannick M.
How to change the schema ? where to ?
Shyju
Is Changing schema for each tables reasonable ?
Shyju
Well if you're using the database for tests during development sure.
Yannick M.
A: 

Look up sp_changeobjectowner in Books on line. That will help you change the owner. The real question is how the object got created to a specific owner to begin with. If this is true on prod, you could have some major issues with other people accesssing the database.

HLGEM
When using integrated security newly created database objects are bound to the current user
Yannick M.
I always specify dbo in my creation scripts
HLGEM