Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register todayThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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
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.
int
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
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)
Events
Mar 31, 11 PM - Apr 2, 11 PM
The biggest SQL, Fabric and Power BI learning event. March 31 – April 2. Use code FABINSIDER to save $400.
Register today