edwin edwin - 9 months ago 51
SQL Question

SQL Server sp_columns does not return expected result

I was trying to check the data types of each column.

I have tried the code below.

use AdventureWorks2014;
exec sp_columns Person;

However, the result return something like this.

enter image description here

PS: I am using
sample database.


There are 3 options available for the Query Results

  • Results to Text Ctrl + T

  • Results to Grid Ctrl + D

  • Results to File Ctrl + Shift + F

Currently your results are showing in Text mode. Changing it to Grid mode, you need to press Ctrl + D or simply select the option as in the screenshot below:

Results to Grid

More over, if you are regularly using the sp_columns to get the column details, you can add it as keyboard shortcut by Tools -> Options -> Environment -> Keyboard -> Query Shortcuts.

In the option you can place the sp_columns against the not reserved columns. For an example, I place in the against Ctrl+3.

So the next time you type the tablename in the query analyzer and Press Ctrl + D then Ctrl + 3 you will get your expected result.

enter image description here