-1

I run into a problem in SQL, I don't know how to update table A by replacing its column "Edu" with another column "Level" of table B.

  • Two tables have a relationship in column "Edu"
  • Different data types bt "Edu" (number) & "Level" (Short Text) Can anyone explain why the below code does not work? And kindly suggest a solution. Thanks!

UPDATE A SET A.Edu= CAST(B.Level AS Varchar(Max)) FROM A INNER JOIN B ON A.Edu=B.Edu;

David
  • 1

1 Answers1

0

Maybe an idea. I think your query doesnt work because you try to update a key using a the same time this key, A.Edu.

My solution : create in the table A a column EduBis with same value as Edu.

Then update with A.EduBis=B.Edu in you clause in the join.

jippy13011
  • 11
  • 3
  • Thank you for your reply, I wonder if any way else to replace values directly on the same column. – David Dec 23 '20 at 16:51