SQL Server Performance

check if unique id exist

Discussion in 'Getting Started' started by postonoh, Apr 13, 2010.

  1. postonoh New Member

    How would I write if unique id exist in one table then add the id to a new table and then add the input text boxes in the new table as well.
    may this is a c# forum question but, going to ask anyway.
    table1 projects
    column1 project_id
    column2 projectName
    column3 projectNumber
    table2 Employee
    column1 Employee_id
    column2 project_id
    column3 fname
    column4 lname
    form design:
    dropdownlist box: load all projectname in the projects table
    inputText field: fname
    inputText field: lname

    button: Savebtn
    This is what happen when user click the save button it save the data but create an new entry everytime.
    I need for it check against the dropdownlist box and add the unique id associated with the selected projectname and add the inputText fields into the employee table.
  2. FrankKalis Moderator

    This is indeed more of a question for a C# forum than anything else. A very rough SQL skeleton to test for uniqueness might look like
    IF NOT EXISTS (SELECT 1 FROM table WHERE key_column(s) = < your value to be tested >
    INSERT INTO table... VALUES...

Share This Page