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)
 Query question

Author  Topic 

vladibo
Starting Member

11 Posts

Posted - 2004-06-09 : 10:14:48
I have a list of DB result ordered by something how can retrieve those that start with specific one keeping the same order. Here is an ezample.

SELECT * FROM MyTbl ORDER BY name

ID NAME
------------
30 Aaaa
20 Bbbb
3 Cccc
41 Dddd
5 Eeee
6 Ffff
8 Gggg
7 Hhhh

So I need for example to select 5 starting with 'Cccc' and have this result

ID NAME
------------
3 Cccc
41 Dddd
5 Eeee
6 Ffff
8 Gggg

Thank you in advance

raymondpeacock
Constraint Violating Yak Guru

367 Posts

Posted - 2004-06-09 : 10:27:49
How about

SELECT TOP 5 * FROM MyTbl WHERE name >= 'Cccc' ORDER BY name


Raymond
Go to Top of Page

vladibo
Starting Member

11 Posts

Posted - 2004-06-09 : 10:44:19
Oh Thanks its really simple...
Go to Top of Page
   

- Advertisement -