isnull

SQL Server Check for IsNull and for Zero

社会主义新天地 提交于 2019-12-04 18:29:53
问题 I have the following: set @SomeVariable = @AnotherVariable/isnull(@VariableEqualToZero,1) - 1 If @VariableEqualToZero is null it substitutes the 1. I need it to substitute 1 if @VariableEqualToZero = 0 as well. How do I do this? 回答1: SET @SomeVariable = @AnotherVariable / COALESCE( CASE WHEN @VariableEqualToZero = 0 THEN 1 ELSE @VariableEqualToZero END, 1) - 1 回答2: If you're using SQL Server, you can probably use a NULLIF statement? i.e. set the value to NULL if it's 0 then set it to 1 if it

how to check for null with a ng-if values in a view with angularjs?

大兔子大兔子 提交于 2019-12-04 14:56:30
问题 i have this situation <div ng-repeat="test in current"> <div ng-if="test.view == null"> <i class="icon ion-checkmark"></i> </div> </div> but test.view== null doesn't work, neither just checking for test.view or test.view == '' any ideas? thanks edit: in the loop, sometimes test.view , has a value sometimes is NULL if i do: <div ng-if="!test.view">1</div> <div ng-if="test.view">2</div> i will only see 1 回答1: You should check for !test , here is a fiddle showing that. 回答2: See the correct way

Check if array value isset and is null

北战南征 提交于 2019-12-03 22:43:52
How to check if array variable $a = array('a'=>1, 'c'=>null); is set and is null. function check($array, $key) { if (isset($array[$key])) { if (is_null($array[$key])) { echo $key . ' is null'; } echo $key . ' is set'; } } check($a, 'a'); check($a, 'b'); check($a, 'c'); Is it possible in PHP to have function which will check if $a['c'] is null and if $a['b'] exist without "PHP Notice: ..." errors? Use array_key_exists() instead of isset() , because isset() will return false if the variable is null , whereas array_key_exists() just checks if the key exists in the array: function check($array,

Check if variable is_undefined in PHP

冷暖自知 提交于 2019-12-03 16:54:14
问题 In PHP, I want to check if a variable has not been set/defined, where setting a variable NULL is considered set/defined . I'm aware everything here: http://php.net/manual/en/types.comparisons.php including isset(), empty(), and is_null(). None of these appear to be what I'm looking for. Consider the following example: <?php $myNull = null; echo 'isset($myNull): "'.isset($myNull).'"<br />'; echo '$myNull value = "'.$myNull . '"<br />'; echo "<br />"; echo 'isset($myUndefined): "'.isset(

how to check for null with a ng-if values in a view with angularjs?

风格不统一 提交于 2019-12-03 09:18:23
i have this situation <div ng-repeat="test in current"> <div ng-if="test.view == null"> <i class="icon ion-checkmark"></i> </div> </div> but test.view== null doesn't work, neither just checking for test.view or test.view == '' any ideas? thanks edit: in the loop, sometimes test.view , has a value sometimes is NULL if i do: <div ng-if="!test.view">1</div> <div ng-if="test.view">2</div> i will only see 1 You should check for !test , here is a fiddle showing that . See the correct way with your example: <div ng-if="!test.view">1</div> <div ng-if="!!test.view">2</div> Regards, Nicholls You can

Why IsNull is twice slow as coalesce (same query)?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-03 09:06:06
We met a strange situation on SQL Server 2008 (SP1) - 10.0.2531.0 (X64) - Win2008 SP2 (X64). Here is a one heavy query: select t1.id, t2.id from t1, t2 where t1.id = t2.ext_id and isnull(t1.vchCol1, 'Null') = isnull(t2.vchCol1, 'Null') and isnull(t1.vchCol2, 'Null') = isnull(t2.vchCol2, 'Null') .... and about 10 more comparisons with Isnull UPD : All columns in comparison (except IDs) are varchar (~30...200) T1 is ~130mln rows, T2 is ~300k rows. These query on rather big Dev server run ~5 hours - this is slow, but what we can do? And while we investigated possible ways of optimisation - we

TSQL ORDER BY with nulls first or last (at bottom or top)

安稳与你 提交于 2019-12-03 06:46:11
问题 I have a date column which has some NULL . I want to order by the date column ASC, but I need the NULL s to be at the bottom. How to do it on TSQL ? 回答1: In standard SQL you can specify where to put nulls: order by col asc nulls first order by col asc nulls last order by col desc nulls first order by col desc nulls last but T-SQL doesn't comply with the standard here. The order of NULLs depends on whether you sort ascending or descending in T-SQL: order by col asc -- implies nulls first order

Check if variable is_undefined in PHP

百般思念 提交于 2019-12-03 06:01:01
In PHP, I want to check if a variable has not been set/defined, where setting a variable NULL is considered set/defined . I'm aware everything here: http://php.net/manual/en/types.comparisons.php including isset(), empty(), and is_null(). None of these appear to be what I'm looking for. Consider the following example: <?php $myNull = null; echo 'isset($myNull): "'.isset($myNull).'"<br />'; echo '$myNull value = "'.$myNull . '"<br />'; echo "<br />"; echo 'isset($myUndefined): "'.isset($myUndefined).'"<br />'; echo '$myUndefined value = "'.$myUndefined . '"<br />'; ?> This example outputs

What is the best way to extend null check?

删除回忆录丶 提交于 2019-12-02 22:50:36
You all do this: public void Proc(object parameter) { if (parameter == null) throw new ArgumentNullException("parameter"); // Main code. } Jon Skeet once mentioned that he sometimes uses the extension to do this check so you can do just: parameter.ThrowIfNull("parameter"); So I come of with two implementations of this extension and I don't know which one is the best. First: internal static void ThrowIfNull<T>(this T o, string paramName) where T : class { if (o == null) throw new ArgumentNullException(paramName); } Second: internal static void ThrowIfNull(this object o, string paramName) { if

TSQL ORDER BY with nulls first or last (at bottom or top)

二次信任 提交于 2019-12-02 22:18:14
I have a date column which has some NULL . I want to order by the date column ASC, but I need the NULL s to be at the bottom. How to do it on TSQL ? In standard SQL you can specify where to put nulls: order by col asc nulls first order by col asc nulls last order by col desc nulls first order by col desc nulls last but T-SQL doesn't comply with the standard here. The order of NULLs depends on whether you sort ascending or descending in T-SQL: order by col asc -- implies nulls first order by col desc -- implies nulls last With integers you could simply sort by the negatives: order by -col asc -