ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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

user-image
تم إضافة السؤال من قبل shyam sunder singh , 15 , ao software solution
تاريخ النشر: 2013/11/30
مستخدم محذوف‎
من قبل مستخدم محذوف‎

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
من قبل 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
من قبل 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
من قبل 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
من قبل 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 ?

المزيد من الأسئلة المماثلة