3> CREATE TABLE #MyNames (FullName VarChar(50))
4> GO
1> INSERT INTO #MyNames (FullName) SELECT 'Fred
2~ INSERT INTO #MyNames (FullName) SELECT 'Wilma
3> INSERT INTO #MyNames (FullName) SELECT 'Barney
4~ INSERT INTO #MyNames (FullName) SELECT 'Betty
5> INSERT INTO #MyNames (FullName) SELECT 'George
6~ INSERT INTO #MyNames (FullName) SELECT 'Jane
7>
8> SELECT
9> SUBSTRING(FullName, 1, CHARINDEX(' ', FullName) - 1) AS FirstName
10> , SUBSTRING(FullName, CHARINDEX(' ', FullName) + 1, LEN(FullName)) AS LastName
11> FROM #MyNames
12> GO
(1 rows affected)
(1 rows affected)
(1 rows affected)
FirstName LastName
-------------------------------------------------- --------------------------------------------------
Fred
INSERT INTO #MyNames (FullName) SELECT
Barney
INSERT INTO #MyNames (FullName) SELECT
George
INSERT INTO #MyNames (FullName) SELECT
(3 rows affected)
1>
2>
3> drop table #MyNames;
4> GO
1>