July 7, 2005 at 9:34 am
Mark,
You could try this query:
select * from INFORMATION_SCHEMA.KEY_COLUMN_USAGE
Good Luck,
Darrell
July 7, 2005 at 9:52 am
Yes indeed - there's more than 1 way to skin this cat...
don't forget to add "where table_name = 'TableName' to Darrell's query!
psarrell - I've been meaning to thank you for your comments the other day ..sorry about doing so on a completely different and irrelevant post but want to do it before I forget...<:-)
**ASCII stupid question, get a stupid ANSI !!!**
July 7, 2005 at 10:18 am
Sorry sushila! You are right! My fault.
The test database I am working with has no primary keys in any tables. When I used your query with another database, I can see that indeed the rows in sysobjects beginning with PK expose primary keys.
One more question....
How do I determine the NAME of the primary key column? Nothing in the SYSOBJECTS table seems to tie it to SYSCOLUMNS.
Thanks!
Mark
July 7, 2005 at 10:28 am
Here's ONE way...
using Darrell's query:
select column_name from INFORMATION_SCHEMA.KEY_COLUMN_USAGE
where table_name = 'TableName' and constraint_name like 'PK%'
**ASCII stupid question, get a stupid ANSI !!!**
July 7, 2005 at 10:45 am
sushila,
You are welcome for the comments!
July 7, 2005 at 10:48 am
Darrell - as Remi is my current role model (may change next week)...
hth! Amen! <:-)
**ASCII stupid question, get a stupid ANSI !!!**
July 7, 2005 at 10:52 am
All that because I'm going on vacation???
July 7, 2005 at 10:57 am
Yes indeed - for Phill may well take your place and beat you at your own game!
hth!!!
**ASCII stupid question, get a stupid ANSI !!!**
July 7, 2005 at 11:00 am
So be it... have other things to do on my vacations .
July 7, 2005 at 11:01 am
Amen!
**ASCII stupid question, get a stupid ANSI !!!**
July 7, 2005 at 11:54 am
Thanks to all. This query works great!
select column_name from INFORMATION_SCHEMA.KEY_COLUMN_USAGE
where table_name = 'TableName' and constraint_name like 'PK%'
What does HTH mean?
Mark
July 7, 2005 at 12:30 pm
Hope that/this helps!
I've been learning a whole bunch of acronyms ever since I became a member - I frequently play guessing games myself....!!!
**ASCII stupid question, get a stupid ANSI !!!**
July 7, 2005 at 12:38 pm
Oops, I thaught it meant happy to help .
July 7, 2005 at 12:46 pm
That works too - as does "heart to heart", "hell this hurts" etc. depending on the context...and splly. for you Remi - for the coming 2 weeks - "hit the highway"....!!!
**ASCII stupid question, get a stupid ANSI !!!**
July 7, 2005 at 12:49 pm
HTP
Hit the poolroom (hard) .
Viewing 15 posts - 16 through 30 (of 35 total)
You must be logged in to reply to this topic. Login to reply