Solved

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

Posted on 2016-10-20
4
39 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 65

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 65

Expert Comment

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

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

756 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