Click here to Skip to main content
15,887,831 members
Home / Discussions / Database
   

Database

 
QuestionNeed some help with deleting process Pin
MarkB77711-Sep-08 22:15
MarkB77711-Sep-08 22:15 
AnswerRe: Need some help with deleting process Pin
Blue_Boy11-Sep-08 22:22
Blue_Boy11-Sep-08 22:22 
GeneralRe: Need some help with deleting process Pin
MarkB77711-Sep-08 23:17
MarkB77711-Sep-08 23:17 
GeneralRe: Need some help with deleting process Pin
Blue_Boy11-Sep-08 23:42
Blue_Boy11-Sep-08 23:42 
GeneralRe: Need some help with deleting process Pin
dojohansen12-Sep-08 1:31
dojohansen12-Sep-08 1:31 
AnswerRe: Need some help with deleting process Pin
razov12-Sep-08 0:11
razov12-Sep-08 0:11 
GeneralRe: Need some help with deleting process Pin
MarkB77712-Sep-08 0:17
MarkB77712-Sep-08 0:17 
GeneralRe: Need some help with deleting process Pin
razov12-Sep-08 0:37
razov12-Sep-08 0:37 
For foreign key dependencies either you can look in th DB documentation(if any) or create a DB Diagram.

Here is one query using the INFORMATION_SCHEMA views that returns both sides of all FOREIGN KEY relationships, as well as the name of the foreign key constraint.

SELECT 
    FK_Table  = FK.TABLE_NAME, 
    FK_Column = CU.COLUMN_NAME, 
    PK_Table  = PK.TABLE_NAME, 
    PK_Column = PT.COLUMN_NAME, 
    Constraint_Name = C.CONSTRAINT_NAME 
FROM 
    INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS C 
    INNER JOIN 
    INFORMATION_SCHEMA.TABLE_CONSTRAINTS FK 
        ON C.CONSTRAINT_NAME = FK.CONSTRAINT_NAME 
    INNER JOIN 
    INFORMATION_SCHEMA.TABLE_CONSTRAINTS PK 
        ON C.UNIQUE_CONSTRAINT_NAME = PK.CONSTRAINT_NAME 
    INNER JOIN 
    INFORMATION_SCHEMA.KEY_COLUMN_USAGE CU 
        ON C.CONSTRAINT_NAME = CU.CONSTRAINT_NAME 
    INNER JOIN 
    ( 
        SELECT 
            i1.TABLE_NAME, i2.COLUMN_NAME 
        FROM 
            INFORMATION_SCHEMA.TABLE_CONSTRAINTS i1 
            INNER JOIN 
            INFORMATION_SCHEMA.KEY_COLUMN_USAGE i2 
            ON i1.CONSTRAINT_NAME = i2.CONSTRAINT_NAME 
            WHERE i1.CONSTRAINT_TYPE = 'PRIMARY KEY' 
    ) PT 
    ON PT.TABLE_NAME = PK.TABLE_NAME 
-- optional: 
ORDER BY 
    1,2,3,4


If you want to limit it to specific tables, you can add any of the following immediately prior to the optional ORDER BY clause:

WHERE PK.TABLE_NAME='something'

WHERE FK.TABLE_NAME='something'

WHERE PK.TABLE_NAME IN ('one_thing', 'another')

WHERE FK.TABLE_NAME IN ('one_thing', 'another')


Hope this solves your problem.
GeneralRe: Need some help with deleting process Pin
MarkB77712-Sep-08 0:44
MarkB77712-Sep-08 0:44 
GeneralRe: Need some help with deleting process Pin
razov12-Sep-08 0:50
razov12-Sep-08 0:50 
AnswerRe: Need some help with deleting process Pin
nelsonpaixao12-Sep-08 14:36
nelsonpaixao12-Sep-08 14:36 
QuestionHow to get the first and last record in every group? Pin
followait11-Sep-08 20:18
followait11-Sep-08 20:18 
AnswerRe: How to get the first and last record in every group? Pin
Blue_Boy11-Sep-08 20:43
Blue_Boy11-Sep-08 20:43 
GeneralRe: How to get the first and last record in every group? Pin
followait11-Sep-08 21:53
followait11-Sep-08 21:53 
GeneralRe: How to get the first and last record in every group? Pin
Blue_Boy11-Sep-08 22:17
Blue_Boy11-Sep-08 22:17 
GeneralRe: How to get the first and last record in every group? Pin
followait12-Sep-08 6:15
followait12-Sep-08 6:15 
GeneralRe: How to get the first and last record in every group? Pin
followait12-Sep-08 17:20
followait12-Sep-08 17:20 
QuestionNested Stored Procedure Pin
jonhbt11-Sep-08 19:51
jonhbt11-Sep-08 19:51 
AnswerRe: Nested Stored Procedure Pin
Ashfield11-Sep-08 20:55
Ashfield11-Sep-08 20:55 
AnswerRe: Nested Stored Procedure Pin
Mycroft Holmes11-Sep-08 20:58
professionalMycroft Holmes11-Sep-08 20:58 
GeneralRe: Nested Stored Procedure Pin
Venkat Eswaran12-Sep-08 7:02
Venkat Eswaran12-Sep-08 7:02 
GeneralRe: Nested Stored Procedure Pin
Mycroft Holmes12-Sep-08 12:47
professionalMycroft Holmes12-Sep-08 12:47 
QuestionProblem while importing data to Microsoft Sql Server 2005 from .csv file Pin
a_b11111-Sep-08 19:15
a_b11111-Sep-08 19:15 
AnswerRe: Problem while importing data to Microsoft Sql Server 2005 from .csv file Pin
Ashfield11-Sep-08 20:58
Ashfield11-Sep-08 20:58 
AnswerRe: Problem while importing data to Microsoft Sql Server 2005 from .csv file Pin
Mycroft Holmes11-Sep-08 21:02
professionalMycroft Holmes11-Sep-08 21:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.