I have to copy text field from one record to another on the same table.
Can you help me?
Can you help me?
--Create our test table Create table table1 (ID int, TextField varchar(10)) --Insert a few test rows with a key and a text data field Insert into table1 Select 1, 'Test 1' Union All Select 2, 'Test 2' Union All Select 3, 'Test 3' Union All Select 4, 'Test 4' --Display our table Select * From table1 /* Results ID TextField ----------- ---------- 1 Test 1 2 Test 2 3 Test 3 4 Test 4 (4 row(s) affected) */ (4 row(s) affected) --Update the contents of record 3 with the text data from record 1 Update table1 Set TextField = A.TextField From (Select * From table1 Where ID = 1) A Where table1.ID = 3 --Display our table again with the new updated record 3 Select * From table1 /*Results ID TextField ----------- ---------- 1 Test 1 2 Test 2 3 Test 1 4 Test 4 (4 row(s) affected) */
Comment