I can get the columns of a table in sql server using this query:
select * from information_schema.columns where table_name = 'MyTable'
but How do I find the foreign key columns associated with that table?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It’s inside
information_schema.table_constraints.EDIT:
Wait, I think
information_schema.key_column_usageis better:And then if you need to make sure that it is really a foreign key, query table_constraints using the constraint name that you got from above: