SQL code for searching part of a string

  • Can someone tell me what SQL code I can use to search for the first few characters in a string? I'm populating dropdownlists based on search criteria using a dataview and RowFilter so I wanted to say populate it based on it's first few characters (or however many are typed in the search text box)

    I thought there was a : BEGINS WITH ' some text' kind of code, but I was wrong. Any help for my newbie question is appreciated.

    Thanks in advance

  • Either your question is vague, or you have missed the obvious:

    SELECT MyField FROM MyTable WHERE MyField LIKE 'ABC%'

  • Thanks...I was just going to post that I got it.

    Yes LIKE is something I didn't know too well

    I never dealt with SQL in college...I'm hardcore new at it and trying to pick it up...thanks

  • No problem.

    Look up SELECT in Books Online and read the entire boring section. It's pretty useful.

    Spend some time learning about doing SET-Based operations. Read some of Jeff Moden's postings on this site. One of the biggest mistakes developers often make is underestimating how different T-SQL is from most other programming languages.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply