SQL Error Msg 208, Level 16, State 1, Line 1
-
Tuesday, February 17, 2009 6:34 PMI am attempting to execute the following query "select * from master GO" in MS SQL Server Management Studio Express on MS SQL Server 2005 with the following error message "Msg 208, Level 16, State 1, Line 1 Invalid object name 'master'.". Note I can see the database in the objects explorer pane. Also this is a new install and my first experience with the tool and SQL on a PC. What am I missing format, path, security ?
All Replies
-
Wednesday, February 18, 2009 5:46 AMModerator
SELECT * FROM _________
Needs to reference a table or view - not a database. The database contains tables and views.
Try this:(note that you don't need to switch to master to query information_schema.columns - I just did it to tie in with your example).USE master GO SELECT * FROM INFORMATION_SCHEMA.COLUMNS
Does this help?
Aaron Alton | thehobt.blogspot.com -
Wednesday, February 18, 2009 5:56 AMModeratorMaster is the name of the database (system db). You need to query the objects like tables or views etc.
Select * from tablename
Select * from viewname
Consider the below query where i create a new table named Employee in master database.
USE master
GO
CREATE table Employee
(
Empid int,
Empname varchar(30)
)
GO
INSERT INTO Employee VALUES(1,'John')
INSERT INTO Employee VALUES(2,'Tom')
INSERT INTO Employee VALUES(3,'Mike')
GO
--I am querying the table from within the master database
Use master
Select * from Employee
--I can also query it by specifying the dbname.schemaname.objectname as follows
Select * from master.dbo.Employee
--The below is the 4 part naming convention of using the servername.dbname.schemaname.Objectname
Select * from [PC0032\SQLEXPRESS].master.dbo.Employee
where dbo=is the default schema name.
-Deepak
Deepak | Mark the answers if it helps to solve your problem |

