Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 size parameters, datatypes

Author  Topic 

basicconfiguration
Constraint Violating Yak Guru

358 Posts

Posted - 2012-07-23 : 13:49:24
1. How do I find the datatype size. eg. varchar(50). Result = 50
2. How do I find the parameter size. eg. Declare @parm varchar(100). Result = 100

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2012-07-23 : 14:13:21
SELECT CHARACTER_MAXIMUM_LENGTH, *
FROM INFORMATION_SCHEMA.COLUMNS

SELECT CHARACTER_MAXIMUM_LENGTH, *
FROM INFORMATION_SCHEMA.PARAMETERS
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-23 : 15:11:30
for numeric datatypes like Numeric,Decimal,float etc you can get scale,precision etc values from NUMERIC_PRECISION and NUMERIC_SCALE columns of the above views

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-07-23 : 15:37:40
For local variables, you can use SQL_VARIANT_PROPERTY:
	DECLARE @parm varchar(100) = 'abcd';
SELECT SQL_VARIANT_PROPERTY(@parm,'MaxLength'), SQL_VARIANT_PROPERTY(@parm,'BaseType');
Go to Top of Page

basicconfiguration
Constraint Violating Yak Guru

358 Posts

Posted - 2012-07-24 : 16:28:09
thanks, i solved this.
Go to Top of Page
   

- Advertisement -