• Hi Lau.

    I made it work at last using some code I found on the internet (credit to a chap from India called chiragkhabaria).

    Replace the code for cur_constraints with this:

    DECLARE cur_constraints CURSOR FOR

    SELECT Cons.XType, Cons.[Name] FROM SysObjects AS Cons

    INNER JOIN (Select [Name],[ID] From SysObjects Where XType = 'U) AS Tab ON Tab.[ID] = Cons.[Parent_Obj]

    INNER JOIN sysconstraints ON sysconstraints.Constid = Cons.[ID]

    INNER JOIN SysColumns Col ON Col.[ColID] = sysconstraints.[ColID] AND Col.[ID] = Tab.[ID]

    WHERE (Tab.[Name] = @table) AND (Col.[Name] = @column)

    It can probably be written in a better way but it looks like it does the job.

    M