Hi Guys i want to share my knowledge
Suppose You have to find a Length of the string in the SQL Statement
suppose you have to find the length of the string
so you include the following statement
Declare @Str varchar(100)
set @Str=' Vaibhav ';
select LEN(@str)
select DATALENGTH(@str)
Guess what will be the output of the following statements..?
Anyone guess what the output will come
output comes for first 7 and for the
last it gives 9 why is it so..?
because length function or len function in SQL Server will not count any spaces
it counts the no of characters and eliminate the spaces
if u have spaces in your string so for that u will have to use
DATA Length function of the sql which will count the spaces
the syntax is same as for Data Length function.
Give me any suggestion guys as i am new here for writing this article on SQL so give suggestions and comment ..!
regarding my post.
Suppose You have to find a Length of the string in the SQL Statement
suppose you have to find the length of the string
so you include the following statement
Declare @Str varchar(100)
set @Str=' Vaibhav ';
select LEN(@str)
select DATALENGTH(@str)
Guess what will be the output of the following statements..?
Anyone guess what the output will come
output comes for first 7 and for the
last it gives 9 why is it so..?
because length function or len function in SQL Server will not count any spaces
it counts the no of characters and eliminate the spaces
if u have spaces in your string so for that u will have to use
DATA Length function of the sql which will count the spaces
the syntax is same as for Data Length function.
Give me any suggestion guys as i am new here for writing this article on SQL so give suggestions and comment ..!
regarding my post.
No comments:
Post a Comment