By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,843 Members | 2,311 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,843 IT Pros & Developers. It's quick & easy.

how to select primary key

100+
P: 254
hi

I want to select primary key field from my table.

code which I tried SELECT FLIGHT_NO FROM FLIGHT. here FLIGHT_NO is primary key. but I am getting error : Invalid Column Name

but this code works fine in Access and MySql.

so what will be the right query ?
Oct 23 '08 #1
Share this Question
Share on Google+
4 Replies


code green
Expert 100+
P: 1,726
I use all three database types you mention and am aware of some pitfalls.
Nothing is obviously wrong.
Do you have backticks or brackets around the field name or table name?
Can we see the exact query used in the three DBs.
Do you have such a field in the MsSql table?
Oct 23 '08 #2

ck9663
Expert 2.5K+
P: 2,878
Are you trying to find the value of the column? Or are you trying to find out what is the PRIMARY KEY of the table?

If it's the former a simple

select ColumnName from YourTable.

if it's the latter,

sp_help YourTable

will show the PRIMARY KEY constraint...usually at the end.

-- CK
Oct 24 '08 #3

100+
P: 254
Are you trying to find the value of the column? Or are you trying to find out what is the PRIMARY KEY of the table?

If it's the former a simple

select ColumnName from YourTable.

if it's the latter,

sp_help YourTable

will show the PRIMARY KEY constraint...usually at the end.

-- CK
Hi

problem was resolved. actually i was putting bracket in the field name
which was unnecessary.

thanks !
Oct 24 '08 #4

code green
Expert 100+
P: 1,726
Ah! The square brackets used by Access.
Access and SQL server queries are not cross platform.
In fact Access seems to be more similar to MySql
Oct 24 '08 #5

Post your reply

Sign in to post your reply or Sign up for a free account.