IF @xml IS NULL PRINT 'It's null!'
Or to perform more actions, like this:
IF @xml IS NULL
BEGIN
SELECT 'XML is NULL'
PRINT 'XML is NULL'
END
Question
I'm working with SQL Server 2012 express and I want to check if the result of a Select is null.
This is my sql statement:
Set @xml = (Select DATOS from LOTES_ANTERIORES WHERE NOMBRE_LOTE = @nombreLote AND PRODUCTO = @producto)
SET @xmlString = cast(@xml as nvarchar(max))
How can I check if @xml
is null?
I'm not sure if @xmlString
will return null or not if @xml
is null.
Solution
IF @xml IS NULL PRINT 'It's null!'
Or to perform more actions, like this:
IF @xml IS NULL
BEGIN
SELECT 'XML is NULL'
PRINT 'XML is NULL'
END