Results 1 to 5 of 5

Thread: Con Cat In Ate

  1. #1
    Join Date
    Jan 2004
    Posts
    11

    Question Unanswered: Con Cat In Ate

    I have a first name and a last name, in two different fields. I use a simple bit of SQL to show them together.

    SELECT
    {fn concat(dbo.table_employee.first_name , dbo.table_employee.last_name)}
    FROM
    dbo.table_employee

    Gives me results like BradWilliams and DarWilliams and such.

    Simple enough. But, it would be nice to put a space between first name and last name. And that is sending me for a loop. Any advise?

    Thanks,
    Dan

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    Dan
    why do it at SQL level - do it at the presentation / UI level, unless you have a direct need - ie the export from the SQL goes to another process.

    how do you handle null forenames. depending on the SQL engine you are using you could write a function to do this.

  3. #3
    Join Date
    Aug 2003
    Location
    West
    Posts
    101

    Con Cat In Ate

    SELECT
    {fn concat (dbo.table_employee.first_name,
    {fn concat (' ', dbo.table_employee.last_name)})}
    FROM
    dbo.table_employee

  4. #4
    Join Date
    Jan 2004
    Posts
    11
    Perfect, Ida, that got it, thank you

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    I wouldn't go so far as 'perfect'
    say Fname= "Dan", SName="Srobe"
    SQL returns: "Dan_Srobe"
    say Fname= SName="Dansrobe"
    SQL returns: "_Dansrobe", when I'm guessing you would want "Dansrobe" with no space "_".
    It becomes more of a problem if you want to build a name from say Title,FName,SName,Qualifications where you could end up with
    "__Dansrobe_"

    still if it works appropriately then maybe it is "perfect" after all.

Posting Permissions

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