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.
| Author |
Topic |
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2005-08-25 : 21:13:29
|
| I have a table "USERS" with a column "USERNAME"I want to create a stored procedure that SELECTs all unique records with a unique first 2 characters when passed the first character.For example, I would like to pass the letter "A" to the SPROCI would like 1 unique record returned for each username starting with "A" & xx = any other characterExample results would look something likeaa,ab,ac,ae,ag,ai,......Any suggestions ? This seems like a bit of a tricky one. The purpose of this is for a directory displayed on a website, and I do not want links to users displayed if there are not any corresponding users so I want to filter out this information. Technically I don't need the username brought back, just the first 2 letters of it.Thanks alot for any help,Mike123 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-08-25 : 21:56:53
|
| how about:select distinct left(username,2) as First2Letters from dbo.users where username like @firstletter + '%'Be One with the OptimizerTG |
 |
|
|
mike123
Master Smack Fu Yak Hacker
1462 Posts |
Posted - 2005-08-25 : 22:33:30
|
| perfect! thank you very much :)mike123 |
 |
|
|
|
|
|