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.
| Author |
Topic |
|
silviorp
Starting Member
2 Posts |
Posted - 2011-09-15 : 12:12:58
|
| Hi guys.I have a table with the following structure:OBJ_GROUP_ID -- BACKUP_STATUS_ID -- DESCRIPTION 0 || 1 || No restriction 1 || 0 || nullI need a query that scan my table, find the first row that the BACKUP_STATUS_ID is 0 and update that row. How should I do that?The rest of this job depends on this information!Thanks in advance! |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2011-09-15 : 12:40:32
|
| UPDATE yourTableSET yourColumn = somevalueWHERE obj_group id = (select min(obj_group_id) from yourTable where BACKUP_STATUS_ID = 0)JimEveryday I learn something that somebody else already knew |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-15 : 12:41:42
|
| is OBJ_GROUP_ID unique valued column?------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
silviorp
Starting Member
2 Posts |
Posted - 2011-09-15 : 13:10:03
|
| jimf, your code works when updating the backup_status_id. I just have to update the backup_status_id and the description.I`m new to sql and that`s not what I was supposed to work with but I`m trying. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-09-15 : 13:23:17
|
| [code]UPDATE yourTableSET BACKUP_STATUS_ID = somevalue,DESCRIPTION=someothervalueWHERE obj_group id = (select min(obj_group_id) from yourTable where BACKUP_STATUS_ID = 0)[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|