Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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

user-image
Question ajoutée par shyam sunder singh , 15 , ao software solution
Date de publication: 2013/11/30
Utilisateur supprimé
par Utilisateur supprimé

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
par 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
par 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
par 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
par 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