Thursday, June 27, 2013

SQL split using Parsename

Interesting way to SPLIT stuff in SQL

Parsename, read all about it, here
DECLARE @FullName VARCHAR(100)
SET @FullName = 'John Doe'

SELECT PARSENAME(REPLACE(@FullName, ' ', '.'), 2) AS [FirstName],
PARSENAME(REPLACE(@FullName, ' ', '.'), 1) AS [LastName]

No comments: