Checking Table dependancies fron Store Procedure

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Sanjay80
    New Member
    • Jan 2007
    • 1

    Checking Table dependancies fron Store Procedure

    I want to Update one table but same time if any column from table ishaving Primary kay or Foreign Kay it should not allow me to do so. I am writting Stored Procedure
  • iburyak
    Recognized Expert Top Contributor
    • Nov 2006
    • 1016

    #2
    Try this:

    [PHP]If not exists(select b.name
    from sysconstraints a
    join sysobjects b on a.constid = b.id
    where a.id = object_id('tabl e_name_here'))

    BEGIN


    -- your update here.

    END[/PHP]

    Comment

    • iburyak
      Recognized Expert Top Contributor
      • Nov 2006
      • 1016

      #3
      Correction

      [PHP]If not exists(select b.name
      from sysconstraints a
      join sysobjects b on a.constid = b.id
      where a.id = object_id('tabl e_name_here')
      and b.xtype in ('PK', 'F'))

      BEGIN


      -- your update here.

      END [/PHP]

      Comment

      Working...