Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Can Someone help me with the replace function?

Author  Topic 

mistylove98
Starting Member

5 Posts

Posted - 2015-04-20 : 10:45:16
I have a query made up of 4 columns the first is the char name length second title third first and last intial and the last column should show the employee phone number without the () I must use the replace function but I can not find an example of it can someone tell me how to use it to get rid of the () thanks here is the query


SELECT 'Your full name is ' + CAST(LEN(FirstName) + LEN(LastName) AS VARCHAR(12)) + ' character(s).' AS [Length of Employee Name],
CASE TitleOfCourtesy WHEN 'Mr.' THEN 'Mister ' WHEN 'mrs. ' THEN 'Miss' WHEN 'Ms.' THEN 'Miss ' WHEN 'Dr.' THEN 'Doctor ' ELSE '' END + TitleOfCourtesy + LastName
AS title, SUBSTRING(FirstName, 1, 1) + SUBSTRING(LastName, 1, 1) AS [First and last Name Initial]
FROM dbo.Employees

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-04-20 : 12:01:00
https://msdn.microsoft.com/en-us/library/ms186862.aspx
Go to Top of Page
   

- Advertisement -