Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2010
    Posts
    12

    Unanswered: SQL Column update with comparison with another table

    I upload data from a Txt File(Txt_Temp) where i have VinNumber with 6 digits. Another table name Resrve_Temp1 where i have Vinumber with 17 digit. now i need to update the vinnumber 6 digit to 17 digit or to new column in Txt_temp.
    Txt_Temp - Table


    I tried this code with no succes and only one row is updating
    update Txt_Temp Set Txt_Temp.Vinnumber=dbo.R_ResrvStock.Vin
    from dbo.R_ResrvStock inner join Txt_Temp on Right (dbo.R_ResrvStock.Vin,6)=Txt_Temp.VinNumber
    OR
    Add this code in view
    Select dbo.R_ResrvStock.Vin,R_Txt_Temp.Vinnumber,R_Txt_Te mp.Model_Code
    from dbo.R_ResrvStock inner join R_Txt_Temp on Right (dbo.R_ResrvStock.Vin,6)=R_Txt_Temp.VinNumber

    Vin
    123456
    123123
    123789
    Resrve_Temp1 - Table
    asddfghjklk123654
    asddfghjklk123456
    asddfghjklk321564
    asddfghjklk123123
    asddfghjklk123789
    asddfghjklk654655
    asddfghjklk456465

    My Result can be in Txt_Temp table or new table or with one or two columns
    asddfghjklk123456 123456
    asddfghjklk123123 123123
    asddfghjklk123789 123789

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    You realize it is not very safe to do this?
    The last six digits of a VIN are simply serially generated. They could easily be duplicated across two different vehicles.
    That said, you should be able to update by joining your six digit VIN to the right six digits of your full VIN. What is the datatype of the full VIN column?
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •