Cómo eliminar los espacios en blanco en SQL

Cómo eliminar los espacios en blanco en SQL

La función LTRIM y RTRIM en SQL se utiliza para eliminar los espacios en blanco de una cadena. LTRIM elimina los espacios de lado izquierdo de la cadena y RTRIM los de lado derecho.

LTRIM(string): Elimina todos los espacios en blanco del comienzo de la cadena.

RTRIM(string): Elimina todos los espacios en blanco del final de la cadena.

REPLACE(string, caracter a remplazar, caracter por el que se remplaza ): Remplaza todos los caracteres que encuentra en el string.

 

Ejemplo 1

SELECT LTRIM(RTRIM('   Sample   '));
Resultado: 'Sample'

 Ejemplo 2

SELECT LTRIM('   Sample   ');
Resultado:'Sample   '

Ejemplo 3

SELECT RTRIM('   Sample   ');
Resultado:'   Sample'

Ejemplo 4

SELECT replace('   Sample Hola  ', ' ', ''); 
Resultado:'SampleHola'

 

Compartir

Comentarios (7)

  • Oatley Responder

    My family all the time say that I am wasting my time here at net, except I know I am getting knowledge daily by reading thes pleasant articles or reviews.

    Thursday, June 8, 2017 7:02 AM
  • Barnum Responder

    Good day I am so thrilled I found your web site, I really found you by mistake, while I was browsing on Google for something else, Anyways I am here now and would just like to say many thanks for a fantastic post and a all round interesting blog (I also love the theme/design), I don’t have time to read it all at the moment but I have book-marked it and also included your RSS feeds, so when I have time I will be back to read a lot more, Please do keep up the superb jo.

    Friday, June 16, 2017 7:10 AM
  • Nestor Responder

    Good article. I am going through a few of these issues as well..

    Thursday, June 22, 2017 3:09 PM
  • Le Hunte Responder

    I see you don't monetize your blog, don't waste your traffic, you can earn extra cash every month because you've got hi quality content. If you want to know what is the best adsense alternative, type in google: adsense alternative Mertiso's tips

    Friday, August 4, 2017 4:30 PM
  • Trevascus Responder

    cheap auto insurance cheap car insurance cheap car insurance cheap auto insurance

    Tuesday, August 22, 2017 12:05 AM
  • Sinclair Responder

    Fb is the primary social media website on this planet.

    Saturday, September 2, 2017 1:23 PM
  • Bateman Responder

    Then they will know that you're a vegetarian.

    Monday, September 4, 2017 10:39 PM

Animate deja un comentario!!!

Eres un humano?

Últimos Tweets

Contáctanos

  • Dirección: Plutarco Elias Calles 243, Granjas México, Iztacalco, DF.

  • Teléfono:55-2712-3820 o 55-4164-9484

  • Email: info@developerji.com