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
 Transact-SQL (2000)
 ORDER BY Doesn't work

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-05-10 : 07:55:46
Wesley writes "Al of my Users have Groups in Columns... the order of these Groups is set by GroupPosition. On deleting a Group
I would like to renumber the position of a group. This should be very easy with this little query.
CREATE PROCEDURE [dbo].[spRenumberUserColumnGroups]
@GroupColumn TINYINT,
@GroupUserId INT
AS

UPDATE tblGroups
SET GroupPosition = ((SELECT COUNT(*) FROM tblGroups gr2 WHERE gr2.GroupPosition <= GroupPosition AND gr2.GroupUserId = @GroupUserId AND gr2.GroupColumn = @GroupColumn)-1)
WHERE GroupUserId = @GroupUserId AND GroupColumn = @GroupColumn
ORDER BY GroupPosition;
GO


Unfortunately it compiles only when I delete that last ORDER BY. I get a message which doesn't say anything to me:
There was an error saving the stored procedure.
[Microsoft][ODBC SQL Server Driver][SQL Server]Onjuiste syntaxis bij het trefwoord ORDER.
(partly dutch)

Can any of you guys explain this nasty little error to me?

Cheers,
Wes"

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2005-05-10 : 09:30:44
You should check the syntax of the UPDATE statement in SQL Server Books Online.

There is no ORDER BY in the UPDATE statement.

CODO ERGO SUM
Go to Top of Page
   

- Advertisement -