Wrox Programmer Forums
Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
|
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 5th, 2003, 09:31 AM
Registered User
 
Join Date: Jul 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Updating data with a cursor

I've created a cursor to select all rows from a table and have an ORDER BY clause in the select statement. If I try to update the data in the table, SQL Server gives me an error stating that the cursor is read only. If I select the data without the ORDER BY clause, there is no problem. Is there a way to update the table with the ORDER BY clause in the select statement of the cursor?

Thanks!!!
 
Old August 5th, 2003, 06:44 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Why are you using a cursor? Chances are you can do what you want without the cursor.

regards
David Cameron
 
Old August 10th, 2003, 08:14 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

And in any case, why would you want to update rows in a particular order? What difference does the order make when you do an update?

The reason why the cursor is not updateable is because of the presence of the ORDER BY clause. The clause means that the cursor has created a temporary table to sort the rows. Allowing the update would mean you would update the temporary table - not terribly useful...

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
Magnetic Cursor - Target Area Cursor? gcarcass .NET Framework 2.0 1 May 5th, 2008 07:20 AM
Updating data from a report ? palli Reporting Services 0 May 28th, 2007 12:32 PM
Updating Recordsets with LockType and Cursor Type arimakidd Classic ASP Databases 7 August 1st, 2005 09:23 PM
how to execute the cursor for online data entries madhuri.sirsat SQL Server 2000 2 April 13th, 2005 11:03 PM
Get data from oracle cursor avinash sharma LNCT ADO.NET 0 January 5th, 2005 04:39 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.