updatestatement

  • Employee table

    EmployeeID Employeename Employeecode Passportcode

    1 aaaa 087878

    2 bbbb 067678

    Passport table

    EmployeeId passport code

    1 02344

    2 02343

    How can i update this passport code in the employee table

    using update statement any body plz help me.

  • Hi there,

    Which version of SQL are you using as I see you have posted this on 2000 and 2005 forums

    Please could you remove one of them?

    Thanks

    Chris

    ----------------------------------------------
    Try to learn something about everything and everything about something. - Thomas Henry Huxley

    :w00t:
    Posting Best Practices[/url]
    Numbers / Tally Tables[/url]

    SQL-4-Life
  • Update employee set Passportcode = Passport.Passportcode

    From PassPort WHERE Employee.employeeId = PassPort .PassportId.

    I suggest you look into BOL and try it out yourself. then if you have doubts ask here. ๐Ÿ™‚

    "Keep Trying"

  • here we are using two table so we can use join right

  • kumar99ms (8/27/2008)


    here we are using two table so we can use join right

    Yes.

    I suggest you look into BOL and try it out yourself. then if you have doubts ask here.

    CONCUR...

    karthik

  • kumar99ms (8/27/2008)


    Employee table

    EmployeeID Employeename Employeecode Passportcode

    1 aaaa 087878

    2 bbbb 067678

    Passport table

    EmployeeId passport code

    1 02344

    2 02343

    How can i update this passport code in the employee table

    using update statement any body plz help me.

    UPDATE e SET Passportcode = p.Passportcode

    FROM Employee e

    INNER JOIN Passport p ON p.EmployeeId = e.EmployeeId

    โ€œWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.โ€ - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • i am using the above query any performance issue come in future

  • How much data is there in your tables and how much more data will be there in the tables in the future.

    "Keep Trying"

Viewing 8 posts - 1 through 7 (of 7 total)

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