We've been building tools to create scripts for various SQL Server T-SQL objects for a long time. Part of scripting a table is the scripting of the data type. That means its datatype name, precision, scale, and maximum length.
In our free SDU Tools for developers and DBAs, we added a scalar function called FormatDataTypeName ot make that easy. It takes the following parameters:
@DataTypeNamesysname the name of the data type
@Precisionint the decimal or numeric precision
@Scaleint the scale for the value
@MaximumLength the maximum length of string values
You can see the outcome in the main image above.
You can see FormatDataTypeName in action here:
To become an SDU Insider and to get our free tools and eBooks, please just visit here:
http://sdutools.sqldownunder.com