Wrox Programmer Forums
|
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 June 28th, 2007, 05:48 AM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 114
Thanks: 0
Thanked 0 Times in 0 Posts
Default Adding an Order to Table

Is there a way to get the record number as part of a SQL query?

Code:
SELECT * FROM EMPLOYEE ORDER BY SURNAME

RECNO  FORENAME  SURNAME 
-----  --------  --------
1      John      Smith
2      Dave      Jones
3      Lee       Williams
Of course, RECNO is not in the EMPLOYEE table.

Regards,

Sean Anderson
__________________
Regards,

Sean Anderson
 
Old June 28th, 2007, 05:33 PM
Authorized User
 
Join Date: Oct 2005
Posts: 72
Thanks: 0
Thanked 0 Times in 0 Posts
Default

In SQL Server 2000, one way to do this is to put the records in a temporary table where the table contains an identity column that will serve as your RECNO column.

SQL Server Helper
How well do you know SQL? Find out with the free test assessment from SQL Server Helper!!!
http://www.sql-server-helper.com/free-test/default.aspx

Got a SQL Server Question? Ask us here: http://www.sql-server-helper.com/forums/default.asp





Similar Threads
Thread Thread Starter Forum Replies Last Post
copy set of data to another table with order by vk18 SQL Server 2000 2 August 23rd, 2013 11:21 AM
Access will not preserve the table order. Admiral_Hook Access 4 April 23rd, 2008 02:43 PM
System to order rows a table DB anteojo Classic ASP Databases 1 December 2nd, 2004 02:34 AM





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