Search code examples
sqlsql-serverssms-2014

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 AdventureWorks sample database.


Solution

  • 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 Options you can place the sp_columns against the not reserved columns. For an example, I placed it against the Ctrl + 3.

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

    Steps to add the shortcut