WiseOwl Training - Established 1992 Wise Owl Training

Established May 1992
30 years in business
Wise Owl Training
30 years in business
See 520 reviews for our classroom and online training
A list of one owl's 5 favourite system stored procedures in SQL!
Part three of a six-part series of blogs

Everyone has a favourite system stored procedure (you do, don't you?). But five? That's the subject of this blog, anyway.

  1. My 5 favourite SQL system stored procedures!
  2. Listing the contents of a procedure or function (sp_helptext)
  3. Using sp_datatype_info to get the data type of a variable (this blog)
  4. Which tables/procedures depend on which? (sp_depends)
  5. Listing the columns in a table (sp_columns)
  6. Using sp_help to get help on a table, procedure, column, etc

Posted by Andy Brown on 03 February 2017

You need a minimum screen resolution of about 700 pixels width to see our blogs. This is because they contain diagrams and tables which would not be viewable easily on a mobile phone or small laptop. Please use a larger tablet, notebook or desktop computer, or change your screen resolution settings.

Using sp_datatype_info to get the data type of a variable

Unless you have committed all of the SQL data types to memory, there'll be times when you want to remind yourself of how big an int really is, or what a varchar is and does.  Here's how to get an answer!  You can either get a full list:

-- show all data types


This gives the following:

List of data types

There are many more columns and rows than are shown here.


Or you could be more specific:

-- show info on subset of data types

sp_datatype_info -9

This would show you a rather odd subset of data types:

Data types -9

Again, there are more columns than are shown here!


Quite why nvarchar and date belong in the same group, but varchar doesn't, I'm not sure!

This blog has 0 threads Add post