Declare a varchar variable : Declare Variables « Transact SQL « SQL Server / T-SQL






Declare a varchar variable


1> -- DATALENGTH(): returns the number of bytes used to manage a value.
2>
3> DECLARE @Value VarChar(20)
4> SET @Value = 'abc'
5>
6> SELECT DATALENGTH(@Value)
7> GO

-----------
          3

(1 rows affected)
1>
           
       








Related examples in the same category

1.Declare a variable
2.Use declared variable in SQL statement
3.Declares a local variable (@intvar) and then assigns a value to the variable
4.Table Variables