Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2007
    Posts
    2

    Unanswered: Transact-SQL Script

    I have a table named conversion. In this table there is not a field for "first name", but only a field for "last name" and "Contact Name". The "Contact Name" holds the full name (First and Last), and the "Last Name" holds the last name.

    In theory I was thinking that I could take the "Last Name" field and subtract the amount of characters + 1 additional (to account for space in between Contact Name Field - FirstName LastName) and then I would have the first name?

    I can find the amount of characters in a field name by using this:

    SELECT LEN(lastname_column) AS 'Length', lastname_column
    FROM conv

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    I think you'll find that name strings are messier than that, and there aren't any simple rules that will reliably parse them.
    Try running this script to create a function on your database that you can call to parse out any part of a name string:

    blindman
    Attached Files Attached Files
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Mar 2007
    Posts
    2
    Thanks for the quick response, the script and the insight! I figured I would need to change my approach on this...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •