locked
First Name and Last Name RRS feed

  • Question

  • User-318857992 posted

    i want to know that should first name and last should be kept as sperate field or merged into single attribute..


    The Basic problem i am facing to keep first name and last name in seperate fields is that i cannot effectively use like query for searching a record by name

    Thursday, May 13, 2010 3:38 AM

Answers

  • User2090264947 posted

    Keep these two fields separate. It will create any problem...see

    select (FName +' ' + LName) as MyName
    from Your_Table_Name with (nolock)
    where (FName +' ' + LName) like '%part_of_your_name%'

    In this scenario if you keep your FName and LName separate later if you required to get only FName or LName, it will be much more easier

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 13, 2010 4:14 AM

All replies

  • User2090264947 posted

    Keep these two fields separate. It will create any problem...see

    select (FName +' ' + LName) as MyName
    from Your_Table_Name with (nolock)
    where (FName +' ' + LName) like '%part_of_your_name%'

    In this scenario if you keep your FName and LName separate later if you required to get only FName or LName, it will be much more easier

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, May 13, 2010 4:14 AM
  • User-979158534 posted

    Hi,

    This decision may vary from application to application. So in some case in mail template the fashion is only to use firstname so in that case you need first name and last name seperate.

    here, i have taken an example of mail it may any auto generated document for conversation, invoice etc.

    Also, It is difficult to extract firstname from merged string firstname + lastname ( in case of merged field) as when required. becasue it is prone to error somebody is writing Jignesh Trivedi and other may Trivedi Jignesh but in both the case firstname is jignesh so very difficult to bifergate.

    Thanks.

    Regards,

    Jignesh

     

     

     

     

    Thursday, May 13, 2010 4:16 AM
  • User377791177 posted

    The Basic problem i am facing to keep first name and last name in seperate fields is that i cannot effectively use like query for searching a record by name


    Then keep both under one field only. There is no thumb rule on whether to create two string columns or put the string in one column. These points can be ignored while normalizing your database. HOwever, i think that in a case whre there are two names

    1. Rashid Parvez

    2. Parvez Musharraf.

    if you search parvez you'll get two records in one column scheme, and one record in two column scheme Cool

    Thursday, May 13, 2010 4:26 AM
  • User294545519 posted

    I would say keep it as First Name and Last Name.

    Its easier to merge First Name and Last Name into 'Full Name', than splitting a 'Full Name' into just First Name or Last Name.

    Thursday, May 13, 2010 4:29 AM
  • User-595703101 posted

    Hi,

    I think the best solution is keeping Firstname and Lastname as seperate fields.

    And in the table create an other field which is a computed field named Fullname.

    Let Fullname column definition as LTRIM(RTRIM(ISNULL(FirstName, '') + SPACE(1) + ISNULL(LastName, '')))

    Of course you can alter the equation according to your design.

    There is a very similar sample with computed column on first name and last name at How to Use Computed Column SQL Server Databases

    I hope that helps,

    Eralper

    Thursday, May 13, 2010 4:44 AM
  • User-2082239438 posted

    Hi,

    I think the best solution is keeping Firstname and Lastname as seperate fields.

    And in the table create an other field which is a computed field named Fullname.

    Let Fullname column definition as LTRIM(RTRIM(ISNULL(FirstName, '') + SPACE(1) + ISNULL(LastName, '')))

    Of course you can alter the equation according to your design.

    There is a very similar sample with computed column on first name and last name at How to Use Computed Column SQL Server Databases

    I hope that helps,

    Eralper


    Sorry i m not agree with this..

    I think use both field as separate column....For searching use full text...

    Thursday, May 13, 2010 4:48 AM
  • User-595703101 posted

    Fulltext Search is a better alternative of course. 

    If it is enabled on the SQL Server, but I think SQL2008 or R2 is a better version to depend on fulltext search.

    Thursday, May 13, 2010 5:02 AM