468,242 Members | 1,537 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,242 developers. It's quick & easy.

how to select primary key

254 100+
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
4 3492
code green
1,726 Expert 1GB
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
2,878 Expert 2GB
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
mukeshrasm
254 100+
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
1,726 Expert 1GB
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.

Similar topics

reply views Thread by Anthony Altieri | last post: by
6 posts views Thread by Patrick | last post: by
3 posts views Thread by stefaan.lhermitte | last post: by
6 posts views Thread by jazpar | last post: by
7 posts views Thread by Brian | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.