GETANSINULL (Transact-SQL)

Applies to: SQL Server Azure SQL Database Azure SQL Managed Instance

Returns the default nullability for the database for this session.

Transact-SQL syntax conventions

Syntax

GETANSINULL ( [ 'database' ] )  

Arguments

'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.

Return Types

int

Remarks

GETANSINULL returns 1 if the database's nullability allows for null values. This return value also requires that the column or data type nullability isn't explicitly defined. The ANSI NULL default is 1.

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

Examples

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

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

Here's the result set.

------  
1  

(1 row(s) affected)

See Also

System Functions (Transact-SQL)