SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 File with new connection (mgmt studio)
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

cddot
Starting Member

37 Posts

Posted - 02/11/2009 :  02:23:35  Show Profile  Reply with Quote
Selecting this menu option, I am prompt to login so I click Connect to login, but I get this error when trying to run a query:

Msg 208, Level 16, State 1, Line 1
Invalid object name 'mytab1'.

I can query the table fine if I start with a New Query. What else do I need to do?

This is SQLServer 2005.

Edited by - cddot on 02/11/2009 02:27:43

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 02/11/2009 :  02:55:17  Show Profile  Reply with Quote
Probably because you are running the query against master database. When you make the new connection, you will be connected to the server with your default database selected, which may be master database or another database.
Go to Top of Page

cddot
Starting Member

37 Posts

Posted - 02/11/2009 :  03:20:49  Show Profile  Reply with Quote
That would be it. Next question, where/how can I change the default connection?
Go to Top of Page

sunitabeck
Flowing Fount of Yak Knowledge

5155 Posts

Posted - 02/11/2009 :  03:48:39  Show Profile  Reply with Quote
ALTER LOGIN loginNameHere WITH DEFAULT_DATABASE=databaseNameHere

or, if you are using SQL 2005, in SQL Management Studio, in object explorer, under server->security->logins, right click on the user name and select properties. There will be a drop down where you can change the default database.
Go to Top of Page

cddot
Starting Member

37 Posts

Posted - 02/11/2009 :  04:38:49  Show Profile  Reply with Quote
Thank you.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000