Free for PREMIUM members
Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium
Declare @str varchar(100) = 'Doe, John a'
SELECT LEFT(@str, CHARINDEX (',', @str, 1) - 1) as last_name,
RIGHT(@str, LEN(@str) - CHARINDEX (',', @str, 1) - 1 ) as first_name
Open in new window
CREATE TABLE MyTable
INSERT INTO MyTable
('Doe, John a')
cross apply (select CHARINDEX (',', debtorname + ',', 1), len(debtorname) ) as ca1 (pos1, len1)
cross apply (select
LEFT(debtorname, pos1 - 1)
, case when pos1 > len1 then null
else RIGHT(debtorname, len1 - (pos1 + 1))
) as ca2 (last_name, first_name)
| LAST_NAME | FIRST_NAME | DEBTORNAME |
| Flintstone | Fred | Flintstone, Fred |
| PortletPaul | (null) | PortletPaul |
| Doe | John a | Doe, John a |
Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.