question

sqlrookie avatar image
sqlrookie asked

Update column from another table

In a database there are two tables which has different columns except for one column that has varbinary(max) column. I want to move the table B varbinary(max) column data into table A varbinary(max) column, in the sense need to update table A. I have found few solutions but they use join or should have relation between the tables like foreign key. Table A has primary key and table B is heap. I tried adding an id column to both as primary key, but table A primary key has relation to many other tables so can't drop primary key from table A. Please need solution to update the column in TableA from TableB with out using join.
tablesforeign-key
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Squirrel avatar image Squirrel commented ·
please post the table schema and identify the relationship between the 2 tables
0 Likes 0 ·

1 Answer

·
Grant Fritchey avatar image
Grant Fritchey answered
You don't have to use a JOIN operation to do this. You can simply: UPDATE TableA SET Column1 = b.Column FROM TableB AS b WHERE TableA.SomeIdentifier = b.Someotheridentifier But, you must have a mechanism for matching one row to the other. You can't be planning to just randomly connect these two tables up, right? There is some data relatnship? Use that in the WHERE clause.
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

sqlrookie avatar image sqlrookie commented ·
Thanks Grant, i am able to solve my issue now.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.