Solved

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

Posted on 2016-10-20
4
24 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 82

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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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…

762 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

19 Experts available now in Live!

Get 1:1 Help Now