binki
binki

Reputation: 8308

How to enter the text 'NULL' (with quotes) into SSMS cell?

I have a table with some VARCHAR(MAX) columns in it. If I open SSMS and right-click on the table and say “Edit Top 200 Rows”, I can select that cell within a row and enter many different arbitrary values. What I want to do is update that cell to the value 'NULL' which would be similar to running this SQL command:

UPDATE dbo.TableName SET ColumnName = '''NULL''' WHERE Id = 1;

However, when I write 'NULL' into the editor’s cell, the effect is that the string NULL is written into the table. I.e., the editor behaves as if this command was executed instead of putting in the text I want:

UPDATE dbo.TableName SET ColumnName = 'NULL' WHERE Id = 1;

How do I use the editor to set the value of the cell to 'NULL'? To clarify, I want the value of the cell to be a 6 character string. The characters in this string are, in order, single quote, capital N, capital U, capital L, capital L, and single quote. How do I achieve this using the “Edit Top 200 Rows” table editor’s Results Pane in SQL Server Management Studio?

The documentation doesn’t seem to mention this scenario. I have opened a docs bug.

Note that this question is not the same as How to enter 'NULL' into SSMS cell?

Upvotes: 0

Views: 314

Answers (1)

Julian
Julian

Reputation: 36730

Found a way! (Warning: need some steps!)

  1. Go to Edit

    enter image description here

  2. Change type to 'Insert Values'

    enter image description here

  3. Show criteria pane

    enter image description here

  4. Type '''NULL''' (so surrounded with triple quotes)

    enter image description here

  5. Execute (e.g. Ctrl + R)

proof:

enter image description here

I hope this is what you're looking for. It has some steps, but at least you don't need to write SQL.

Upvotes: 1

Related Questions