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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 updating a single record from a derived table

Author  Topic 

Kanati
Starting Member

36 Posts

Posted - 2002-09-19 : 17:41:21
I'm using a loop without a cursor and using "top 1" to return a single record at a time... And then modifying that record to make it no longer fit the criteria... thereby moving to the next record...
But I am having difficulty updating a single record...

update V1 set terminus = '#' from (select top 1 terminus from ackr where newrsn = '5830710014040010') as V1

The above won't let me update the derived table because of the "top" clause, but there is more than one record that meets the "newrsn =" criteria. I only wish to update the "top 1" record which would be the one I retrieved just prior to that update statement with a "select top 1" query.

Any ideas?

Thanks.

Kanati

LarsG
Constraint Violating Yak Guru

284 Posts

Posted - 2002-09-19 : 18:10:00
If you describe what you are trying to accomplish there certainly are kind enough people on this board that could help you to find a solution that does not involve a cursor.

Go to Top of Page

byrmol
Shed Building SQL Farmer

1591 Posts

Posted - 2002-09-19 : 18:12:11
Kanati,

Try
SET ROWCOUNT 1


DavidM

"SQL-3 is an abomination.."
Go to Top of Page

Kanati
Starting Member

36 Posts

Posted - 2002-09-19 : 18:13:43
AHA! Rowcount = 1... Thanks. Without even looking at what that does I think it sounds pretty self-explanatory.

:)

Thanks again.
Kanati

Go to Top of Page
   

- Advertisement -