Export (0) Print
Expand All
Expand Minimize

GETANSINULL (Transact-SQL)

Returns the default nullability for the database for this session.

Topic link icon Transact-SQL Syntax Conventions


GETANSINULL ( [ 'database' ] )

' database '

Is the name of the database for which to return nullability information. database is either char or nchar. If char, database is implicitly converted to nchar.

When the nullability of the specified database allows for null values and the column or data type nullability is not explicitly defined, GETANSINULL returns 1. This is the ANSI NULL default.

To enable the ANSI NULL default behavior, one of these conditions must be set:

  • ALTER DATABASE database_name SET ANSI_NULL_DEFAULT ON
  • SET ANSI_NULL_DFLT_ON ON
  • SET ANSI_NULL_DFLT_OFF OFF

The following example returns the default nullability for the AdventureWorks database.

USE AdventureWorks;
GO
SELECT GETANSINULL('AdventureWorks')
GO

Here is the result set.

------ 
1      

(1 row(s) affected)
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft