“Podziel ciąg i zdobądź pierwszy i ostatni element na serwerze SQL” Kod odpowiedzi

podzielone imię i nazwisko w SQL

# Name of table = names_table
# Name of column containing names = full_name
# Simply change the table and column name to what corresponds with your dataset

SELECT LEFT(full_name, STRPOS(primary_poc, ' ') -1 ) AS first_name,  
  		RIGHT(full_name, LENGTH(primary_poc) - STRPOS(primary_poc, ' ')) AS last_name, name
FROM names_table;

# NB: This does not capture middle names
Kwams

SQL SERVER Podzielony ciąg Last

SELECT SUBSTRING( string , LEN(string) -  CHARINDEX('/',REVERSE(string)) + 2  , LEN(string)  ) FROM SAMPLE;
Bad Beaver

Podziel ciąg i zdobądź pierwszy i ostatni element na serwerze SQL

DECLARE @String nvarchar(200) = 'I_love_my_country'

SELECT left(@String, charindex('_', @String) - 1) AS first_element 
SELECT reverse(left(reverse(@String), charindex('_', (reverse(@String))+'_' ) -1)) AS last_element 
Tiny Coders

Odpowiedzi podobne do “Podziel ciąg i zdobądź pierwszy i ostatni element na serwerze SQL”

Pytania podobne do “Podziel ciąg i zdobądź pierwszy i ostatni element na serwerze SQL”

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu