How To Assign NULL Values to Variables or Columns?
Submitted by: AdministratorThe rule for assigning NULL values to variables or table columns is simple: Use keyword "NULL" directly as normal values. Specifically,
* "NULL" can be used in SET statements to assign NULL values to variables.
* "NULL" can be used in SET clauses in UPDATE statements.
* "NULL" can be used in value lists in INSERT statements.
* "NULL" can be used in parameter lists when calling stored procedures or functions.
The tutorial script below gives you some good examples:
USE GlobalGuideLineDatabase;
GO
-- assign NULL values to variables
DECLARE @birth_date DATETIME;
SET @birth_date = NULL;
SELECT @birth_date;
GO
-----------------------
NULL
-- assign NULL values to columns
UPDATE ggl_links SET notes = NULL;
GO
(8 row(s) affected)
-- assign NULL values to parameters
EXEC sp_help NULL;
GO
Name
----------------
ggl_links_dump
ggl_links_top
ggl_links_view
...
Submitted by: Administrator
* "NULL" can be used in SET statements to assign NULL values to variables.
* "NULL" can be used in SET clauses in UPDATE statements.
* "NULL" can be used in value lists in INSERT statements.
* "NULL" can be used in parameter lists when calling stored procedures or functions.
The tutorial script below gives you some good examples:
USE GlobalGuideLineDatabase;
GO
-- assign NULL values to variables
DECLARE @birth_date DATETIME;
SET @birth_date = NULL;
SELECT @birth_date;
GO
-----------------------
NULL
-- assign NULL values to columns
UPDATE ggl_links SET notes = NULL;
GO
(8 row(s) affected)
-- assign NULL values to parameters
EXEC sp_help NULL;
GO
Name
----------------
ggl_links_dump
ggl_links_top
ggl_links_view
...
Submitted by: Administrator
Read Online MS SQL Server Job Interview Questions And Answers
Top MS SQL Server Questions
☺ | How To Select Some Specific Rows from a Table in MS SQL Server? |
☺ | PHP MSSQL - How To Display a Past Time in Days, Hours and Minutes? |
☺ | Does Index Slows Down INSERT Statements? |
☺ | How To Execute the Cursor Queries with "OPEN" Statements? |
☺ | What Happens If Strings Are Casted into Wrong Code Pages in MS SQL Server? |
Top Databases Programming Categories
☺ | RDBMS Interview Questions. |
☺ | SQL Interview Questions. |
☺ | SSRS Interview Questions. |
☺ | Database Administrator (DBA) Interview Questions. |
☺ | Sybase Interview Questions. |