Tepken Vannkorn
Tepken Vannkorn

Reputation: 9723

sql server 2008 - t-sql does not recognize column name from the table

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

Answers (2)

Jack Apple
Jack Apple

Reputation: 81

Edit > Intellisense > Refresh Local Cache

Upvotes: 7

Pouyan
Pouyan

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

Related Questions