How to return a special character to a query

Asked

Viewed 335 times

2

Good morning!

It may be simple my question, but I am starting in SQL Server still, so I would like to know how to return in select a special character.

As you can see, there is a simple quotation mark in the Nat_rec field and I can’t put it in a like I think, I’ve tried it in several ways, but I couldn’t filter the records with just the quotation mark. If you can help me with this problem,!

inserir a descrição da imagem aqui

  • Avoid placing the program code or query code inside an image. Put it in same text.

2 answers

5


The character referred to is not called "simple quotation mark" but the apex, although in everyday life we confuse it with the apostrophe. In graphic terms there is a subtle difference between apex and apostrophe.

In the ascii table the apex has the decimal value of 39. There are some ways to select it, being one of them through the function char():

-- código #1
SELECT colunas
  from PC_TabM410
  where Nat_Rec = char(39);
  • 1

    So... I wasn’t sure what the character’s name was, but thank you for clarifying that too. As for the consultation, it was exactly what I was looking for, it also helped me even more by showing me the ASCII Table, because I had no knowledge that existed. Thank you so much, you’ve been a great help.

  • @Danilovilhena In English there are expressions like single quoted and double quoted. In Portuguese, the signs used would correspond to the apostrophe and quotation marks. But, in past times of computing, some "translator" created the term "simple quotes" because he probably did not know the apostrophe. : ( ; In fact, the same "translator" created terms delete (we have the erase), update (we have update) etc. :(

0

select * from PC_Tab410 where MesAno='08/2018' AND Nas_Rec='*'

Where * is the character you want. I advise you to copy the same character from the database to that querry because of the formatting

  • I appreciate the help, but it’s not exactly what I was looking for...

Browser other questions tagged

You are not signed in. Login or sign up in order to post.