Solved

SQL syntax, SEL FROM sys.messages WHERE sys.messages.text LIKE ' %NULL%'

Posted on 2016-10-20
4
49 Views
Last Modified: 2016-10-20
EE,

I am trying to SELECT all sys.messages that contain the text string 'NULL'.
First query shows there is at least 1, message_id = 515.
Second query does not return this record.  I assume there are several messages with the word 'NULL'.
I am using SSMS.

Why does this not work or how do I get all the Records with 'NULL' in the string?

Regards
Sam

SELECT *
FROM sys.messages
WHERE message_id = 515
AND language_id = 1033

SELECT *
FROM sys.messages
WHERE
sys.messages.text LIKE ' %NULL%'
AND language_id = 1033
ORDER BY message_id

Open in new window

0
Comment
Question by:SamCash
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 66

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 41852435
>sys.messages.text LIKE ' %NULL%'
My knee-jerk reaction is to lose the spaces between the left quote mark and the first % sign, as they will be included in the search.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 41852462
If a value is truly NULL, the word NULL will not be found in a string.  That means you can not use LIKE to find it.  This page http://www.w3schools.com/sql/sql_null_values.asp discusses using and finding NULL values.
0
 

Author Closing Comment

by:SamCash
ID: 41852479
Jim,

Thanks much.  This is not the first time a 'space' has kept me going for hours.

Best Regards
Sam
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 41852515
Thanks for the grade, good luck with your project.  -Jim
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question