Reputation: 9723
I tried testing T-SQL in sql server 2008. I have a table name tblStaff
and 3 columns (UserType, UserName, and Password)
. I tried to select UserType from this table by using the following query:
SELECT UserType FROM tblStaff;
When executing, it produces error of "Invalid Column name 'UserType'
". I have no idea.
Any help would be appreciated. Thanks in advance.
Upvotes: 1
Views: 7154
Reputation: 2939
There could be many reasons for this:
1 - on SQL server management studio make sure you are using that specific database ... the default database your new query will execute on is "master" try this : USE YOUR_DATABASE_NAME SELECT UserType FROM tblStaff
2 - make sure you're typing your tablename correctly
3- try using the full path for the table. for example "dbo.tblStaff"
hope this helps
Upvotes: 1