Groups | Blog | Home
all groups > sql server clients > march 2006 >

sql server clients : Syntax - Query


Ysandre
3/8/2006 12:01:30 PM
OK, I have 2 fields: LastName and FirstName.
I need the syntax that will provide me the following:
LastName + ',' + Firstname
However, the field has a max length of 20 characters. So, if the last name
is greater than 18 charaters, then I need it to provide the following:
left(LastName,18) + ',' + left(firstname,1)
But Wait! There's more...
If the last name is less than 18 characters, then I want as much of the
firstname as possible, without exceeding the 20 character limit.
Am I making sense?
Please let me know if this is possible, and if so what the syntax is, given
that lastname and firstname lengths are variable.
Thank you!
Ysandre
3/8/2006 12:31:21 PM
Nevermind, I figured it out. The following provides the results I need:

left((left(lastname,18) + ',' + firstname),20)

Thanks!
kyra

[quoted text, click to view]
AddThis Social Bookmark Button