Sql updation
can we replace a full row in sql server?
5 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Jul 21, 2014, 2:34 AM EDT
Mohit Pandey69 reputationPosted Jul 21, 2014, 2:38 AM EDT
VulpesRank #55 · 29.2K reputationPosted Jul 21, 2014, 2:57 AM EDT
You have to do it instead in either of the ways I gave in my opening post.
If there are only a handful of columns an update is usually easier and you need to include a where clause to identify the row to be replaced.
Jignesh TrivediRank #16 · 50.3K reputationPosted Jul 21, 2014, 3:05 AM EDT
Hi,
you can write update query and replace the value
for example I have DepartmentMasters table and I want to replace row 1 (DepartmentId = 16) to row 2 (DepartmentId = 1) than query become
update DepartmentMasters
set Code = A.Code
FROM
(select * from DepartmentMasters where DepartmentId = 1) A
WHERE DepartmentMasters.DepartmentId = 16
hope this will help you.
Mohit Pandey69 reputationPosted Jul 21, 2014, 7:15 PM EDT