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
 How to output formatting in SQL?

Author  Topic 

nychick
Starting Member

2 Posts

Posted - 2010-10-21 : 00:13:15
How can I select the first letter of the first name and then last name with proper spacing?

I.E.

John Smith is

J. Smith

Sachin.Nand

2937 Posts

Posted - 2010-10-21 : 01:14:27
declare @nm as varchar(20)='John Smith'
select left(@nm,1) + '. ' + substring(@nm,(charindex(' ',@nm)),len(@nm))

PBUH

Go to Top of Page

nychick
Starting Member

2 Posts

Posted - 2010-10-21 : 01:19:08
quote:
Originally posted by Sachin.Nand

declare @nm as varchar(20)='John Smith'
select left(@nm,1) + '. ' + substring(@nm,(charindex(' ',@nm)),len(@nm))

PBUH





thanks for your quick reply. I should of rephrased my question.

I have two columns fname, lname and I need to change the format to F. Lastname of the entire table.

This is in Oracle SQL. Thanks again
Go to Top of Page

Sachin.Nand

2937 Posts

Posted - 2010-10-21 : 01:23:11
This is a SQLServer forum.
Please post in Oracle forum slike

http://www.orafaq.com/forum/ or http://www.club-oracle.com/forums/sql-pl-sql-f6/ as I am not to familiar with the equivalent PL/SQL syntax


PBUH

Go to Top of Page
   

- Advertisement -