Link to home
Start Free TrialLog in
Avatar of m270350
m270350

asked on

SQL Substring How to combine first letter of every word in a column


 Hi,

    I wanted to know How can I combine the first letter of every word seperated by space in a column. I have got the query almost to work, For the second word it finds the result fine but for the third word it seems to go back to the first words first letter for ex:

SELECT     BANK_NAME, SUBSTRING(BANK_NAME, 1, 1) + SUBSTRING(BANK_NAME, CHARINDEX(' ', BANK_NAME) + 1, 1) + SUBSTRING(BANK_NAME,
                      CHARINDEX('  ', BANK_NAME) + 1, 1) AS Expr1
FROM         TBL_BANKS

Returns bob for

ABN Amro Bank         It should display AAB but it displays AAA
Alpha Credit Bank      It should display ACB but it displays ACA


I appreciate any one's help regarding the problem in advance.

ASKER CERTIFIED SOLUTION
Avatar of Brendt Hess
Brendt Hess
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial