Copy data from one column to other column (which is in a different table)

后端 未结 8 1536
小鲜肉
小鲜肉 2020-11-30 20:59

I want to copy data from one column to another column of other table. How can I do that?

I tried the following:

Update tblindiantime Set CountryName          


        
8条回答
  •  日久生厌
    2020-11-30 21:52

    In SQL Server 2008 you can use a multi-table update as follows:

    UPDATE tblindiantime 
    SET tblindiantime.CountryName = contacts.BusinessCountry
    FROM tblindiantime 
    JOIN contacts
    ON -- join condition here
    

    You need a join condition to specify which row should be updated.

    If the target table is currently empty then you should use an INSERT instead:

    INSERT INTO tblindiantime (CountryName)
    SELECT BusinessCountry FROM contacts
    

提交回复
热议问题