kapil190588 (10/2/2012)
can anyone explain me why select len(@a) as 'declared' gives output as 1
The answer to this is available in the explanation to the question( also shown below )
When n (Where n defines the string length) is not specified in a data definition or variable declaration statement, the default length is 1
Hence the two declaration shown below are equivalent
DECLARE @a VARCHAR ='xyz'
DECLARE @a VARCHAR(1) = 'xyz'
How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/