Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Add records from one table to another
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01652499
Message ID:
01652510
Vues:
42
>>>Yes, there are CHARINDEX and SUBSTRING functions in SQL Server. In SQL Server 2016 (I think) they also finally introduced the split function.
>>
>>Thank you.
>
>You're welcome. Play with the select statements first until you get it parsed correctly.
>
>This blog post may help
>
>http://blogs.lessthandot.com/index.php/datamgmt/datadesign/parsing-fullname-field-to-individual/

Thank you. I found this example online and trying to make it work for me:
DECLARE @FullName    VARCHAR(50) = 'Mark Zuckerberg'

SELECT SUBSTRING(@FullName, 1, CHARINDEX(' ', @FullName) - 1) AS [First Name],
       SUBSTRING(@FullName, CHARINDEX(' ', @FullName) + 1, LEN(@FullName)) AS [Last Name]
They have First Name + Last Name and I have Last Name + Comma + First Name. Give me a couple of hours (:)) and I will figure it out.

Update: I got it:
SELECT SUBSTRING(@FullName, 1, CHARINDEX(', ', @FullName) - 1) AS [Last Name],
       SUBSTRING(@FullName, CHARINDEX(', ', @FullName) + 1, LEN(@FullName)) AS [First Name]
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform