Skip to content

Instantly share code, notes, and snippets.

@roe3p
Last active November 16, 2018 11:24
Show Gist options
  • Save roe3p/5b3d4b9e0c0e68c84ce85cd40d60349f to your computer and use it in GitHub Desktop.
Save roe3p/5b3d4b9e0c0e68c84ce85cd40d60349f to your computer and use it in GitHub Desktop.
SQL Stored proc that gets parameter info for another stored proc - required by the VBA module that executes stored procedures
CREATE PROCEDURE usp_GetSPParameters @SPName VARCHAR(50)
AS
BEGIN
SET NOCOUNT ON;
SELECT
Name AS ParameterName,
TYPE_NAME(user_type_id) AS DataType,
max_length AS CharacterMaxLength,
scale AS NumericScale,
precision AS NumericPrecision
--'Prec' = case when type_name(system_type_id) = 'uniqueidentifier'
-- then precision
-- else OdbcPrec(system_type_id, max_length, precision) end,
--'Scale' = OdbcScale(system_type_id, scale),
--'Param_order' = parameter_id,
--'Collation' = convert(sysname,
-- case when system_type_id in (35, 99, 167, 175, 231, 239)
-- then ServerProperty('collation') end)
--,*
FROM sys.parameters
WHERE object_id = object_id(@SPName)
END
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment