How To: Create a SELECT to select records from a table based on the first letter.......

Last post 08-17-2007 5:41 AM by rhaskins. 3 replies.

Sort Posts:

  • How To: Create a SELECT to select records from a table based on the first letter.......

    08-16-2007, 2:42 PM
    • Loading...
    • rhaskins
    • Joined on 04-15-2003, 6:49 AM
    • Posts 6

    Dear All

    I need to cerate a SP that SELECTS all the records from a table WHERE the first letter of each records starts with 'A' or 'B' or 'C' and so on. The letter is passed via a parameter from a aspx web page, I was wondering that someone can help me in the what TSQL to use I am not looking for a solution just a poin in the right direction. Can you help.

     

    Thanks Ross

    Filed under: ,
  • Re: How To: Create a SELECT to select records from a table based on the first letter.......

    08-16-2007, 3:26 PM

    SELECT *

    FROM table

    WHERE columnName LIKE 'A%'


     

    Darrell Norton, MVP
    Darrell Norton's Blog


    Please mark this post as answered if it helped you!
  • Re: How To: Create a SELECT to select records from a table based on the first letter.......

    08-16-2007, 4:02 PM
    • Loading...
    • che3358
    • Joined on 09-25-2003, 10:23 AM
    • Cleveland, OH
    • Posts 802

    @Letter  Varchar(1) 

     

    SELECT *

    FROM YourTableName

    WHERE YourColumnName LIKE  @Letter + '%'

  • Re: How To: Create a SELECT to select records from a table based on the first letter.......

    08-17-2007, 5:41 AM
    • Loading...
    • rhaskins
    • Joined on 04-15-2003, 6:49 AM
    • Posts 6

    Thanks All

     Got it to work using

    SELECT @param = @param + '%'

    SELECT ColName

    FROM Table

    WHERE ColName Like @param

     

    Ross

Page 1 of 1 (4 items)
Microsoft Communities
Page view counter