Linked Questions
48 questions linked to/from How can I list all foreign keys referencing a given table in SQL Server?
1 vote
1 answer
561 views
List sql table relations using query [duplicate]
I have one Employee table in my Database which has relations to different other tables. In my application, When a user try to delete one employee which has relational data in other tables, I want to ...
1 vote
0 answers
211 views
A SQL script to identify all the FKs referencing a table [duplicate]
Possible Duplicate: How can I list all foreign keys referencing a given table in SQL Server 2005? I'm trying to use Information_Schema to find all the FKs referencing a particular table. However ...
-2 votes
1 answer
107 views
How can we know PK and FK relation if we have 200 tables in a database of SQL Server. Is there any query to check it [duplicate]
Apart from database architecture diagram, is there any way to get the list of all the tables with PK/FK relations?
0 votes
1 answer
77 views
Script to output information of foreign keys [duplicate]
I would like to know the detail about my foreign keys. I tried this SELECT * FROM sys.foreign_keys; But I need more than the information I can get now. Is there a way to know the columns they are ...
815 votes
16 answers
718k views
How do I see all foreign keys to a table or column?
In MySQL, how do I get a list of all foreign key constraints pointing to a particular table? a particular column? This is the same thing as this Oracle question, but for MySQL.
500 votes
20 answers
784k views
Select columns from result set of stored procedure
I have a stored procedure that returns 80 columns, and 300 rows. I want to write a select that gets 2 of those columns. Something like SELECT col1, col2 FROM EXEC MyStoredProc 'param1', 'param2' ...
414 votes
11 answers
669k views
How to remove a column from an existing table?
How to remove a column from an existing table? I have a table MEN with Fname and Lname I need to remove the Lname How to do it?
215 votes
17 answers
508k views
How can I find out what FOREIGN KEY constraint references a table in SQL Server?
I am trying to drop a table but getting the following message: Msg 3726, Level 16, State 1, Line 3 Could not drop object 'dbo.UserProfile' because it is referenced by a FOREIGN KEY constraint. ...
173 votes
13 answers
207k views
How to find foreign key dependencies in SQL Server?
How can I find all of the foreign key dependencies on a particular column? What are the different alternatives (graphically in SSMS, queries/views in SQL Server, 3rd party database tools, code in ....
25 votes
7 answers
112k views
Could not drop object 'dbo.Table1' because it is referenced by a FOREIGN KEY constraint
Even though I am removing and trying to drop table, I get error, ALTER TABLE [dbo].[Table1] DROP CONSTRAINT [FK_Table1_Table2] GO DROP TABLE [dbo].[Table1] GO Error Msg 3726, Level 16, State 1, ...
43 votes
1 answer
45k views
How to change the primary key to be non-clustered?
Part-time reluctant DBA here. I want to change an existing primary key index from clustered to non-clustered. And the syntax is escaping me. This is how it's scripted out right now. ALTER TABLE [...
6 votes
3 answers
41k views
Find all foreign keys constraints in database referencing a certain primary key [duplicate]
I want to find all foreign keys in my database that reference to a primary key of a certain table. For example, I have a column A in table T which is the primary key. Now I want to find in which ...
2 votes
2 answers
9k views
copy FOREIGN KEY constraints from one DB to other
I have a local db which has FOREIGN KEY constraints. The live version of this websites DB, does not have any of these FOREIGN KEY constraints. How can I "copy/paste", import/export ONLY the FOREIGN ...
1 vote
4 answers
16k views
How to find all foreign key constraints in oracle?
In StackOverflow, I can find the post about how to find all foreign key constraints in SQL Server. I only can find the post about how to find all foreign key constraints for a table in Oralce (List ...
5 votes
4 answers
6k views
SQL how do you query for tables that refer to a specific foreign key value?
I have table A with a primary key on column ID and tables B,C,D... that have 1 or more columns with foreign key relationships to A.ID. How do I write a query that shows me all tables that contain a ...