sql updation
can we replace a full row in sql server?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Mohit PandeyPosted Jul 21, 2014, 11:15 PM
Jignesh TrivediPosted Jul 21, 2014, 7:05 AM
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.
VulpesPosted Jul 21, 2014, 6:57 AM
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.
Mohit PandeyPosted Jul 21, 2014, 6:38 AM
VulpesPosted Jul 21, 2014, 6:34 AM