sp_help lists columns among other things.
I am trying to get just the results that include the column information.
Has anyone implemented this?
sp_help lists columns among other things.
I am trying to get just the results that include the column information.
Has anyone implemented this?
Do you mean this:
SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE TABLE_NAME = 'YourTable' AND COLUMN_NAME='YourColumn'
This returns info like nullability, datatype, size etc etc
What about EXEC sp_helptext 'sp_help'
and see what you can reuse?
Frank's answer is correct. you can use sp_helptext to look at how system stored procedures are implemented. You can also use OBJECT_DEFINITION to do the same thing:
select OBJECT_DEFINITION(OBJECT_ID('sp_help'))
Although this is probably not what you want. Many of the tables used in these procedures are internal and inaccessible to use in your own code.
Ada's method is probably more of what you actually want. There's also the sys.columns
Dynamic Management View which you can use to get column information in addition to the information schema views. I prefer the DMV's as they are closer to the internal schema.