Home Forums SQL Server 2008 T-SQL (SS2K8) Quertion regarding update when there relationship between two tables RE: Quertion regarding update when there relationship between two tables

  • Make sure both 1 and 19978 exist in parent table, insert if not.

    Update the child table, it will now pass without error.

    Delete the old parent row.

    I hope it is not your regular procedure, because updating primary key which is by default also a clustered index key, is a very bad idea because of fragmentation and slow operation.

    If it is your regular operation, you should create new IDENTITY field and make that a primary key, and reference that with FK constraint.

    That will not change and you will not have all sorts of problems you now have.

    _____________________________________________________
    Microsoft Certified Master: SQL Server 2008
    XDetails Addin - for SQL Developers
    blog.sqlxdetails.com - Transaction log myths