Here is one approach to do this. Take this sample table:
CREATE TABLE Members (
lname VARCHAR(30) NOT lisanssız)
INSERT INTO Members VALUES ('Dunlap')
INSERT INTO Members VALUES ('Davis')
INSERT INTO Members VALUES ('Leon')
Next you can create a stored procedure that will take as parameter the
letter that you want to search by. Here is how it may look:
CREATE PROCEDURE GetMembersByFirstLetter
@letter CHAR(1)
AS
SELECT lname
FROM Members
WHERE lname LIKE @letter + '%'
ORDER BY lname
Note that the above procedure will return all last names that start with the
parameter letter. If you want to return only the first one you can write the
stored procedure as below (the syntax below is for SQL Server 2000, for SQL
Server 2005 replace "TOP 1' with "TOP (1)", note the parentheses):
CREATE PROCEDURE GetMemberByFirstLetter
@letter CHAR(1)
AS
SELECT TOP 1 lname
FROM Members
WHERE lname LIKE @letter + '%'
ORDER BY lname
Then you just need to call the stored procedure in your ASP code and pass
the selected letter. In Query Analyzer or SQL Server Management Studio you
can invoke it like this:
EXEC GetMembersByFirstLetter 'D'
Or to get a single last name:
EXEC GetMemberByFirstLetter 'D'
HTH,
Plamen Ratchev
http://www.SQLStudio.com