Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 select error

Author  Topic 

kesz1
Starting Member

2 Posts

Posted - 2008-06-18 : 00:00:50
Hi

I just restored a bak file to our SQL server Express and I need some help. For some reason, the only time a SQL statement will work is if I add the database name to the front of the table:

select * from dbname.tablename

Below will not work:
select * from tablename

Any thoughts?

raky
Aged Yak Warrior

767 Posts

Posted - 2008-06-18 : 00:36:49
select * from daname.dbo.tablename
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-18 : 00:48:11
quote:
Originally posted by kesz1

Hi

I just restored a bak file to our SQL server Express and I need some help. For some reason, the only time a SQL statement will work is if I add the database name to the front of the table:

select * from dbname.tablename

Below will not work:
select * from tablename

Any thoughts?


probably you're running it against the wrong database. try like this

use [yourdbname]
select * from tablename
Go to Top of Page

kesz1
Starting Member

2 Posts

Posted - 2008-06-18 : 06:41:42
This did the trick:

sp_changeobjectowner 'userName.TableName','dbo'

Now I can run it without referencing the db name in the query.


Thanks for your help.
Go to Top of Page
   

- Advertisement -