Letras de palavras

  • Tenho uma tabela chamada Glossário, que posui uma lista de termos e seus respectivos significados. Criei uma query para listar apenas a primeira letra dos termos. Utilizarei esse resultado para preencher uma lista contendo as letras do alfabeto que possuem resgistros. O problema está nas letras que possuem acentos. Como faço para que sejam listadas as letras sem considerar acentuação ou Maiúsculas e Minusculas?

     

    Obrigado.

     

    SELECT DISTINCT

    LTRIM(SUBSTRING(vocabulo, 1, 1)) as letra

    from tbl_Glossario

  • I don't speak Portugese, and I can't test this, but won't this do the trick for you? By the way, for those following along, he wants to create a row per first letter that is found in the result set, but ignoring accent marks and the like. If you have a better method, or can test this, feel free to jump in.

    SELECT DISTINCT

     LTRIM(SUBSTRING(vocabulo, 1, 1)) COLLATE SQL_Latin1_General_CP1_CI_AI AS letra

    FROM

     tbl_Glossario

  • Tks,

    First, Sorry but my English is the worst at the world. But your code is exactly, that I can do.

    Only one more question, the resultset, in my case is (Á,B,C). How can I obtain only the letter A?

     

     

     

  • I think you could create a table of acceptable letters and join to the table or tables with the accented letters.  In your select, you will pick the column in your table.

    Table X has 1 column COL1 containing

    A

    B

    C....

    Table Y has your data with the accents.

    Select X.COL1

    from Y inner join X on Y.COL1 = X.COL1  (insert proper collation here)

    I think this might work.

    Now I found your initial question interesting. I can read Spanish, so I was able to figure out almost exactly what you were asking.

     

     

     

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply