Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

How to update multiple row in one line command in sql server?

user-image
Question added by shyam sunder singh , 15 , ao software solution
Date Posted: 2013/11/30
Deleted user
by Deleted user

update table using data in other table You can do that by using "join" between the two tables dependence on the  common..........

Anwar Sadat Abdul Baree
by Anwar Sadat Abdul Baree , Computer Programmer , Planet Pharmacies LLC

Update employee set isActive =1 where1=1 /* Which means update same values(isActive=1) in multiple row in that table (employee)*/

Mohamed Yousif
by Mohamed Yousif , .Net developer , Free Lancer

if I understand you , you want to update table using data in other table You can do that by using "join" between the two tables dependence on the  common column between them like this example :

 

Table1 ID

Name1

 

Table2

ID

Name2

 

the update statment :

update Table2

set Name2 = Name1

from Table1 inner join Table2

on Table1.ID = Table2.ID

 

Hope that it helps

zakaria laalami
by zakaria laalami , Sr. Developer , Bloomin Brands International

According to my knowledge, there is no one single statement to update multiple rows at once (trust me i tried). i ended up using a stored procedure. you can create a stored proc, call it in a loop and pass on your values.

taimoor aziz
by taimoor aziz , Senior Developer , Themovechannel

I didint understand your question, means what do you mean by one line command ??

simple update command can aslo update multiple rows !! Do You mean you want to write query in One Line ?

More Questions Like This