The SQL standard requires no guarantee about the order data will be returned in unless it is explicitly ordered using "order by". Some vendors' provide implementations that (most of the time) will return data in the order it was entered. However you cannot and should not rely on this.
You need to provide the table (or table variable) holding the data with a field that can be used to specify order.
The simplest way of achieving this In T-SQL is to provide an Identity column which will automatically increment every time a row is added. See the link in the solution posted by Chill60 above for more information.
SET NOCOUNT ON
DECLARE @Jim TABLE
(
OrderBy int identity(0,1),
KeyField int,
ValueField varchar(50)
)
INSERT INTO @JIM (KeyField, ValueField) VALUES (19 , 'Global')
INSERT INTO @JIM (KeyField, ValueField) VALUES (156111 , 'Calvin')
INSERT INTO @JIM (KeyField, ValueField) VALUES (153211 , 'James A. Garfield ')
INSERT INTO @JIM (KeyField, ValueField) VALUES (152111 , 'James Buchanan')
INSERT INTO @JIM (KeyField, ValueField) VALUES (159211 , 'Lyndon B. Johnson')
INSERT INTO @JIM (KeyField, ValueField) VALUES (150411 , 'Madison')
INSERT INTO @JIM (KeyField, ValueField) VALUES (151211 , 'William Henry Harrison')
INSERT INTO @JIM (KeyField, ValueField) VALUES (154111 , 'William McKinley')
select * from @jim order by orderby asc
Will get you:
OrderBy KeyField ValueField
----------- ----------- --------------------------------------------------
0 19 Global
1 156111 Calvin
2 153211 James A. Garfield
3 152111 James Buchanan
4 159211 Lyndon B. Johnson
5 150411 Madison
6 151211 William Henry Harrison
7 154111 William McKinley