Problem with a query - wrong update results

  • Hello experts,

    I have 2 tables.

    One of the tables has the data I need to know which user input it. On the table I have a column name called owner_m, when I run the data import for some reason my sistem is bringing me instead of the user_names the id_user_numbers that is store in tbluser table.

    I need to update my data table with the users name and I have the following query for that:

    update A

    set final_owner=tblUser.tName

    FROM A INNER JOIN

    tblUser ON cast(A._owner_m as int) = cast(tblUser.aUserID as int)

    owner_m is a varchar and User id is an int. Thats why Im using the cast option.

    But for some reason the query is giving me the same user id for all the fields as follows:

    owner_m tname

    19 Carol

    20 Carol

    28 Carol

    instead of

    19 Carol

    20 Rolando

    28 Estefania.

    Im asumming is because the data type and I already fix that with the cast function.

    I dont know what else to do, please help!!!

  • Change your query to:

    SELECT A.final_owner, tblUser.tName, A._owner_m, cast(A._owner_m as int), tblUser.aUserID, cast(tblUser.aUserID as int)

    FROM A INNER JOIN

    tblUser ON cast(A._owner_m as int) = cast(tblUser.aUserID as int)

    And post the results.

  • I got it...thanks a lot!

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

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