Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Trouble retrieving emoji messages in SQL query and ignored or treated as empty string

I have the "👍" emoji stored as a message in my database. When I execute my store procedure to retrieve records where

select top 10 * 
from t_MemberApp_PushNotifications 
where contactID = 10930547 
  and pushMessage <> '' 
order by 1 desc

It doesn’t display the data when only emoji is present. As you can see the attached images.

Image1
Image2

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I attempted to understand the issue by referring to the provided link, and you can utilize it to address my concern on a SQL Fiddle.
Fiddle Link

>Solution :

Use N for indicating UNICODE string

Select top 10 * from t_MemberApp_PushNotifications 
where contactID = 10930547 and pushMessage <> N'' order by 1 desc

You can use len()

Select top 10 * from t_MemberApp_PushNotifications 
where contactID = 10930547 and LEN(pushMessage) >0  order by 1 desc
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading