Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

295
Vistas
Translate query from MSSQL to PostgreSQL

This query update one column if UserName has only numbers.

UPDATE [dbo].[MyTable]
SET [MyColumn] = CAST(CASE 
            WHEN UserName LIKE '%[^0-9]%'
                THEN 0
            ELSE 1
            END AS BIT)

I need to retranslate it to postgreSql. It must be something like this

UPDATE "MySheme"."MyTable"
SET "MyColumn" = CAST(CASE 
            WHEN "UserName" LIKE '%[^0-9]%'
                THEN 0
            ELSE 1
            END AS BIT)
over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Consider:

update mytable
set mycolumn = (username !~ '\d')::int::bit 

This produces a bit value of 1 if username does not contain any digit, else 0.

Note that Postgres supports the boolean datatype, that would probably make more sense here. This would also simply the query:

update mytable
set mycolumn = (username !~ '\d')

Note that I did not quote the identifiers. Quoted identifiers usually add no value, and make queries unnecessarily lengthy - I would recommend avoiding them in your set up.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda