Hey guys!
In this article, I will share with you a series of options for filtering and separating the number and text of a string using T-SQL functions and commands in SQL Server, which is a very common need in the daily lives of those who develop various SQL queries or want to validate the data in a table.
Creation of the test base
For the examples I will demonstrate in this article, I will use the following script below:
IF (OBJECT_ID('tempdb..#Teste') IS NOT NULL) DROP TABLE #Teste
CREATE TABLE #Teste (
Nr_Documento VARCHAR(50)
)
INSERT INTO #Teste
VALUES
('12345678909'),
('123.456.789-09'),
('Dirceu12345Resende678909.com'),
(' 12345678909 '),
('"12345678909"'),
('d12345678909'),
('12345+6789-09'),
('123456.789'),
('R$ 123456.789'),
('$ 123456.789'),
('+123456.789'),
('-123456.789'),
('Dirceu Resende'),
('Dirceu[Resende]')
How to filter the numeric part and the text part of a string
A very common need is also to filter the numeric part and the text part of a string. Shall we learn how to do this?

Comentários (0)
Carregando comentários…