SQL SERVER Management Studio – Grid vs Text Output

Recently, I had an interesting situation where my client was inserting multiple texts in their text column but their output was always in a straight line. During the Comprehensive Database Performance Health Check, they asked me questions if I know how to fix it. Well, it is actually very simple and we need to learn about Grid vs Text Output.

SQL SERVER Management Studio - Grid vs Text Output TextOutput-800x299

Grid vs Text Output

First, let us open the SQL Server Management Studio (SSMS). Whenever we run any query, the query is visible in the results window. There is three option of how the result of the query will be visible. The first option is text, the second is a grid and the third one is a file.

The short cut for each of the mode is as follows:

  • Text – CTRL + T
  • Grid – CTRL + D
  • File – CTRL + SHIFT + F

Now let us run the following code and observe output when the TEXT and GRID output are enabled.

DECLARE @sVar VARCHAR(100)
SET @sVar = 'SQL
Athority'
SELECT @sVar sVar

Here is the output in TEXT as well as GRID format.

SQL SERVER Management Studio - Grid vs Text Output TextvsGrid

It is very clear from the display that the newline feed is not preserved when the output is displayed in the GRID format. However, if you want the data in the same format as it was inserted, you will have to display it in either text or file format.

If you have any further questions, you can reach out to me on Twitter.

Reference: Pinal Dave (https://blog.sqlauthority.com)

, , , ,
Previous Post
SQL SERVER – Move a Table From One Schema to Another Schema
Next Post
SQL SERVER – Datatype Decimal Explained – Datatype Numeric

Related Posts

1 Comment. Leave new

  • Dharma iyerDharmaraj Nagarajan
    January 15, 2021 8:11 pm

    Is there any reason behind the long running queries are getting timedout in Grid mode output and in text mode its getting completed without issues.

    Reply

Leave a Reply

Menu