Questions tagged [isnull]

`ISNULL` is a proprietary SQL function that replaces NULL with the specified replacement value.

ISNULL is a SQL function that replaces NULL with the specified replacement value.

The ANSI/ISO SQL standard function COALESCE serves the same purpose, and is widely implemented.

Reference

MSDN Article

706 questions
17
votes
4 answers

Finding null value in Dataset - DataRow.IsNull method vs ==DbNull.Value - c#

What are the benefits of using the c# method DataRow.IsNull to determine a null value over checking if the row equals DbNull.value? if(ds.Tables[0].Rows[0].IsNull("ROWNAME")) {do stuff} vs if(ds.Tables[0].Rows[0]["ROWNAME"] == DbNull.value) {do…
Jarrod
  • 1,535
  • 3
  • 16
  • 19
17
votes
7 answers

What is the best way to extend null check?

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…
AgentFire
  • 8,944
  • 8
  • 43
  • 90
16
votes
3 answers

Computed bit column that returns whether another column is null

I try to have this computed column: CREATE TABLE dbo.Item ( ItemId int NOT NULL IDENTITY (1, 1), SpecialItemId int NULL, --I tried this IsSpecialItem AS ISNULL(SpecialItemId, 0) > 0, --I tried this IsSpecialItem AS…
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
15
votes
4 answers

SQL Server Check for IsNull and for Zero

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?
Jeff
  • 8,020
  • 34
  • 99
  • 157
15
votes
7 answers

Check if variable is_undefined in PHP

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…
tjbourke
  • 221
  • 1
  • 2
  • 8
13
votes
7 answers

SQL Server: ISNULL on uniqueidentifier

I am trying to compare a column col1 and a variable @myvar in a WHERE clause. Both usually contain GUIDs, but may also have NULL values. I thought I could get around the fact that NULL=NULL evaluates to FALSE by using WHERE ISNULL(col1,…
TVogt
  • 185
  • 1
  • 1
  • 11
10
votes
3 answers

Python pandas .isnull() does not work on NaT in object dtype

I have this series: ser=pd.Series([11,22,33,np.nan,np.datetime64('nat')],name='my_series') The series looks like this: 0 11 1 22 2 33 3 NaN 4 NaN Name: my_series, dtype: object But I get only one True for NULL…
ragesz
  • 9,009
  • 20
  • 71
  • 88
9
votes
5 answers

Convert native null to string "null"

Is it possible to convert null to string with php? For instance, $string = null; to $string = "null";
Run
  • 54,938
  • 169
  • 450
  • 748
9
votes
3 answers

django order by isnull value?

i have a datetime field which can be null and id like to do qs.order_by('field__isnull', 'name') but this results in: Join on field 'field' not permitted. Did you misspell 'isnull' for the lookup type? Is this possible at all?
Andy
  • 726
  • 2
  • 6
  • 15
9
votes
1 answer

sql server 2008 return value getting shortened when using ISNULL and NULLIF

I have this select statement where I check whether phone number in null or empty and if they are then I would return 'No Phone Number is available'. Like this SELECT Name, ISNULL(NULLIF(Phone, ''), 'No Phone Number is available') AS…
Sidharth
  • 1,251
  • 1
  • 25
  • 40
9
votes
2 answers

Entity Framework ISNULL in Where condition

I have a Query in SQL Server : SELECT * FROM MyTable t WHERE ISNULL(t.Status,'') = '' How I can do it in Entity Framework? EDIT: Oh Sorry my code was like WHERE ISNULL(t.Status,'') = ''
Usman Khalid
  • 3,032
  • 9
  • 41
  • 66
9
votes
3 answers

mysql if not null, 0 or ""

SELECT * FROM table WHERE id IN ('21') AND (content_id IS NULL OR content_id = 0 OR content_id = '') Is there a shorter way of writing this condition. I have a int() column that could be either: NULL, 0 or EMPTY.
John Magnolia
  • 16,769
  • 36
  • 159
  • 270
8
votes
2 answers

How to check if JSON object is empty in Java?

In Java, if I use the following JSON string as an example, how would I check if the objects are empty/null? {"null_object_1" : [], "null_object_2" : [null] } I have tried using: if(!jsonSource.isNull("null_object_1")) {/*null_object_1 is not…
92Jacko
  • 523
  • 2
  • 10
  • 18
8
votes
1 answer

check if a row value is null in spark dataframe

I am using a custom function in pyspark to check a condition for each row in a spark dataframe and add columns if condition is true. The code is as below: from pyspark.sql.types import * from pyspark.sql.functions import * from pyspark.sql import…
8
votes
2 answers

Stored procedure call with an ISNULL in the assignment. Invalid Syntax?

Above the call to this stored procedure is another call to a different stored procedure. The first procedure will assign something to @NewIdentifier if it needs to, otherwise I need to use the default SaleId. exec myStoredProc @SaleId =…
Brandon
  • 68,708
  • 30
  • 194
  • 223
1
2
3
47 48