Compare 2 tables

  • Dear Experts,

    At the moment of insert data into a table using a certain program I would like to check whether the value being input has been inserted before and if so block me. This is a validation from the database side. Am using SQL 2005.

    Anyone here who has done SQL validations ? Any samples here ?

  • Please post table definitions, sample data and desired output. Read this to see the best way to post this to get quick responses.

    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • SQL validations typically are CONSTRAINTs, whether a UNIQUE constraint, or a CHECK constraint. you can also use triggers or even functions as a CHECK constraint...so the tools are there...but...

    As Gail already said, without the specific details of what you want we can't offer anything helpful yet.

    The details require the CREATE TABLE definitions so we know what you are talking about, along with INSERT INTO statements so we have example data to test against.

    explaining the problem, like which specific column/value you are wanting to avoid duplicates with, along with the structure above, can give us all the tools which we need to give you a tested working example for you to test with and understand the concepts.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

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

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