How can I remove certain chars before the space in T-SQL?

I'm trying without any luck to come up with a method to pass

Bruno Miguel Alexandre into B. Miguel Alexandre

and

Bruno Alexandre into B. Alexandre

just in SQL so I can make this part of a big query in a Store Procedure

can anyone provide me with any help? Any function that you guys might already have?

Much appreciated.

Answers


Take 1st character + everything from the space. The 8000 is to avoid LEN calls otherwise

LEFT(MyValue, 1) + '.' + SUBSTRING(MyValue, CHARINDEX(' ', MyValue), 8000)

Need Your Help

best practice for getting Map value from arguments in a method in java?

java map

I want to pass a Map that contains key and value that is Listview,

styling property tag in Struts 2

css jsp struts2 struts2-bootstrap-plugin

I am making use of the Struts2 property tag to get the user name like this.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.