Solved

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

Posted on 2016-10-20
4
33 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
  • 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
SELECT query on two levels (detail and summary) 13 47
This query failed in sql 2014 5 29
Query group by data in SQL Server - cursor? 3 28
error in my cursor 5 10
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

815 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now