mid , left , right

  • If I want to search records starting with '01', this is a possible statement:

    SELECT *

    FROM TableName

    WHERE (LEFT(FieldName, 2) = '01')

    What is the statement to retrive records that have '12009' starting in the character 14 ?

  • Look up SUBSTRING in Books Online. Lookup CHARINDEX as well.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thank you Gila!

    This is the correct statement:

    SELECT *

    FROM TableName

    WHERE (SUBSTRING(FieldName, 14, 5) = '12009')

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

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