34

In SQL Server Management Studio 2012, I was typing/pasting data into a table (via Edit Top 200 Rows). Whenever I typed/pasted NULL in a cell, a NULL value was inserted. Apparently it thought I meant the NULL value instead of the 'NULL' text. Which didn't work, as my column wasn't nullable...

Now how do I enter the 'NULL' text into a cell?

If I wanted to insert the NULL value, I would have pressed Ctrl+0...

miroxlav
  • 11,796
  • 5
  • 58
  • 99
Michel de Ruiter
  • 7,131
  • 5
  • 49
  • 74
  • 6
    I guess a bigger question might be, why do you want a NULL text for something? Can't you just make the column nullable then use the NULL value? :) And, you might have to do it the old school way, if you have a PK on the table, just do it like SET text = 'NULL' WHERE PK = ID. – Joe May 19 '14 at 22:01
  • 1
    @Joe – There can still be number of valid `'NULL'` uses. For example if the table represents a blacklist of SQL keywords. – miroxlav May 21 '14 at 07:31
  • 4
    The answer to my question, "How the heck do you enter NULL in a field again?" was answered in YOUR question... Ctrl + Zero – Scuzzlebutt May 22 '18 at 19:17

2 Answers2

35

Just press CTRL + 0 (why should the answer body longer than 30 cars?)

Oszkar
  • 1,603
  • 3
  • 15
  • 17
  • 2
    This helped me. – user7560542 May 16 '19 at 05:19
  • 1
    The question is how to enter the string expressed via the SQL literal `'NULL'` into a cell (i.e., the four character string formed by the characters `'N'`, `'U'`, `'L'`, and `'L'`). CTRL+0 sets the cell to `NULL` the conceptual non-value value. Please read the question more carefully. – binki Feb 03 '20 at 21:39
27

Just enter 'NULL' (with single quote mark) into cell, SSMS will trim leading and ending single quote mark and save it as string 'NULL'.

Without single quote mark, SSMS will treat input as NULL.

qxg
  • 6,955
  • 1
  • 28
  • 36