Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 update more than 1 row at same time

Author  Topic 

detlion1643
Yak Posting Veteran

67 Posts

Posted - 2010-03-29 : 14:15:28
I have taken over a poorly written database - anyways I'm trying to move forwards on it. I have a table that looks like this:
1,2,3,4,5,6,7 - columns
a,n,n,2,d,n,n - a=number,n=null,d=date
a,n,n,3,d,n,n - a=number,n=null,d=different date then above

a is a primary key in another table, but updating this one table is a nightmare. I first wrote a check to see if a exists, and if it does update with new values if I had any. I ran into this problem where a is shown twice, but only columns 4,5 contain different values.

If I was to run a check to update columns 2,3 where a exists, would it update both rows with the new values for columns 2,3 or would it only update the first row it found? (I am using if exists select...)

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-03-29 : 15:58:58
It would update both the rows where 'a' exists.
Go to Top of Page
   

- Advertisement -