Sunday, February 17, 2013

SQL SERVER STR String function

SQL SERVER STR String function


STR  String function  converts from numeric data to character data.


Ex: Convert numeric value to String using STR function

select str(10.55)

O/P:  11
if u don't specify optional params in STR function, it will be rounded to nearest integer.


Ex: Convert  Money to String using STR String function
declare @sal smallmoney
set @sal = 10000.4555
select str(@sal,8,2)

O/P:10000.46

Note: before decimal it has 5 digits after decimal 4 digits so we need 5 digits+2 digits with decimal digit=8, decimal digits 2.



tags:SQL SERVER STR String function,Convert numeric value to String using STR function,Convert  Money to String using STR String function

No comments:

Post a Comment