Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2016-10-20
4
Medium Priority
?
61 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 2000 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 84

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

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

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

When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Ready to get certified? Check out some courses that help you prepare for third-party exams.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

715 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