Below is code snippet from Powershell
$query = "select MAX(convert(varchar(10),server_time,102))from status_history where status not like ('ERROR FETCHING%')"
$servers = Invoke-Sqlcmd2 -query $query -ServerInstance "100.81.60.2" -Database "temp" -Username "temp" -password "temp"
I need to check in Powershell if the sql query contained in $query returns NULL.
I tried using
if($servers.Column1 -eq NULL)
but it doesnt seem to work.
if($servers.Column1 -eq $null)or just omit it:if ($servers.Column1)if ($servers.Column1)is not a good idea in this context, because values like 0 or "" (empty string) also evaluate to$false. I'd try[DBNull]::Value.Equals().