SQL - Length of FirstName and LastName
I am able to find the length of a person's FirstName and LastName by doing this:
SELECT LEN(FirstName + ' ' + LastName) AS NameLength FROM dbo.Employees
That gives me the length of both the FirstName and LastName as well as the space in between.
What I am trying to accomplish is have the words, "Your full name is (NameLength) characters" I tried to add the two together but I get
You need to cast the number to varchar in order to append it to text, like
select 'your name is ' + cast(LEN(FirstName + ' ' + LastName) as varchar(64)) + ' chars '
(you have this tagged as both mysql and sql-server, so i'll just put a sql-server example here)