sp_helpjoins

Description

Lists the columns in two tables or views that are likely join candidates.

Syntax

sp_helpjoins lefttab, righttab

Parameters

lefttab

is the first table or view.

righttab

is the second table or view. The order of the parameters does not matter.

Examples

Example 1

Displays a list of columns that are likely join candidates in the sales and salesdetail tables:

sp_helpjoins sales, salesdetail

a1       a2       b1       b2       c1       c2
   d1       d2       e1       e2       f1       f2
      g1       g2       h1       h2
-------- -------- -------- -------- -------- -------- 
   -------- -------- -------- -------- -------- -------- 
      -------- -------- -------- -------- 
stor_id  stor_id  ord_num  ord_num  NULL     NULL
   NULL     NULL     NULL     NULL     NULL     NULL
      NULL     NULL     NULL     NULL

Example 2

Displays a list of columns that are likely join candidates in the sysobjects and syscolumns system tables:

sp_helpjoins sysobjects, syscolumns

a1   a2   b1   b2   c1   c2   d1   d2   e1   e2
        f1   f2   g1   g2   h1   h2
---- ---- ---- ---- ---- ---- ---- ---- ---- ----
        ---- ---- ---- ---- ---- ----
id   id   NULL NULL NULL NULL NULL NULL NULL NULL
        NULL NULL NULL NULL NULL NULL

Usage

Permissions

Any user can execute sp_helpjoins.

See also

System procedures sp_commonkey, sp_foreignkey, sp_helpkey, sp_primarykey