BLOGS BY TOPIC▼
BLOGS BY AUTHOR▼
BLOGS BY YEAR▼
Everyone has a favourite system stored procedure (you do, don't you?). But five? That's the subject of this blog, anyway.
- My 5 favourite SQL system stored procedures!
- Listing the contents of a procedure or function (sp_helptext)
- Using sp_datatype_info to get the data type of a variable (this blog)
- Which tables/procedures depend on which? (sp_depends)
- Listing the columns in a table (sp_columns)
- 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
sp_datatype_info
This gives the following:

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:

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!
- My 5 favourite SQL system stored procedures!
- Listing the contents of a procedure or function (sp_helptext)
- Using sp_datatype_info to get the data type of a variable (this blog)
- Which tables/procedures depend on which? (sp_depends)
- Listing the columns in a table (sp_columns)
- Using sp_help to get help on a table, procedure, column, etc