Duplicate record insertion check

  • I have 3 tables Adviser , adviserbranch and customer. adviser has branches under him and customers are associated to the the branches(no direct FK of adviser in customer table) . how can i implement duplicate check at databse layer itself that for an adviser customer should not repeat

  • you can always put a unique index on the fields within the table. What is the Primary Key to the table. You might/should be able to use that

    For better, quicker answers, click on the following...
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • ndixit

    In order to receive help we need you to help us help you.

    Please read the first article in my signature block and post the information accordingly. That is table definitions, sample input and desired output, and how you have attempted to solve the problem.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • I'm going to second what bitbucket has requested. Without full table definitions it is nearly impossible to give accurate advice.

    Based on the information you have provided it doesn't sound like there is a way to do it with a unique constraint, you'll either have to do it in a trigger (insert/update) or in the business logic of the insert/update.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply