help Create Script

  • Hi to All,

    I'm new here and newbies in SQl script. Please help me to create script that will update the record using the data from 2 different database server.

    Here my sample table

    Table1 from other server - on this table i will update the data of row containing specific data as trigger to update

    id Fieldname FieldValue ClassID

    1 Course BS engineering 001

    2 Course bS Medicine 002

    3 Subject Anatomy 002

    4 Grade A+ 002

    5 StudentID 3920 002

    6 Course bs psychology 003

    7 StudentID 7518 003

    8 Subject Anatomy 003

    9 Course Ab Education 004

    10 StudentID 6538 004

    11 Subject English 004

    Table2 from other database server

    ID Name Course StudentNum

    1 Van Doe BS Engineering 6745

    2 John Doe BS Medicine 3920

    3 Victor Joe BS Psychology 7518

    4 Dave Yu AB Education 6538

    I want to update the FieldValue of the Fieldname value of Course in Table1. I want to use the Pivot so i could arrange my data accordingly. See below the possible result of query using Pivot

    ClassID Fieldname FieldValue StudentID

    002 Course bS Medicine 3920

    003 Course bs psychology 7518

    004 Course Ab Education 6538

    using the student id from result of Pivot query we will link it in StudentNum in Table2

    Here the possible result and changes in Table1 with bold data.

    id Fieldname FieldValue ClassID

    1 Course BS engineering 001

    2 Course BS Medicine 002

    3 Subject Anatomy 002

    4 Grade A+ 002

    5 StudentID 3920 002

    6 Course BS Psychology 003

    7 StudentID 7518 003

    8 Subject Anatomy 003

    9 Course AB Education 004

    10 StudentID 6538 004

    11 Subject English 004

    Can you please help me to create a script to produce the above result. Thanks in advance.

    Regards,

    JohnCarlo

  • Hi...can you please post some table/data scripts as per post below.

    Also your expected results based on the sample data you provide.

    Thanks

    Helps us help you

    https://spaghettidba.com/2015/04/24/how-to-post-a-t-sql-question-on-a-public-forum/

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

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

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