aspx Tutorial

.NET Articles,jQuery demo, asp.net with jQuery, online tutorial,Jquery, SilverLight, Javascript, asp.net,JSON, MVC,.NET Articles,demo, Web Services, .NET articles, Sharepoint 2010, visual studio 2010,Aamir Hasan,IT
Advertise Here

Advertize

wwwSW
Posted by Aamir Hasan   on Friday, May 27, 2011 Total Views:  

In this example, you will see how to get the length of a string in T-SQL. Len function returns the numeric. Len function is used to get the length. Len function can be used in SELECT query. Len function takes only one argument

Here’s is an example

CREATE   TABLE PATIENT

    (

      ID BIGINT IDENTITY,

      FULLNAME VARCHAR(100),

      GENDER CHAR,

      DESCRIPTION NVARCHAR(MAX),

      DETAILS TEXT

    )

 

GO

 

INSERT INTO PATIENT

VALUES('AAMIR HASAN','M','--','EMPTY'),

('AWAIS AHMED','M','-','EMPTY'),

('MAHWISH IKTAR','M','--','EMPTY'),

('BILAL AHMED','F','---',NULL),

('SABA KHAN','F','----','-')

GO

SELECT  *

FROM    PATIENT

 

Example 1

 

SELECT  LEN(FULLNAME) AS [FULLNAME LEN],

        LEN(DESCRIPTION) AS [DESCP],

        *

FROM    PATIENT


Output

 

Example 2

 

SELECT  LEN(FULLNAME) AS [FULLNAME LEN],

        LEN(DETAILS) AS [DESCP],

        *

FROM    PATIENT

 

Output

 

Msg 8116, Level 16, State 1, Line 1

Argument data type text is invalid for argument 1 of len function.

When you will try to get the Len of text field column you will always see the error message as shown above.

 

Note: Len function will not work for text field.

 

Protected by Copyscape Online Plagiarism Tool

Comments (6) -

john
john United States
5/28/2011 5:33:32 AM #

he contents are great. Though, there some things that I don't seem to get, but anyway! It;s a very nice post. Thanks for sharing them through the web. Regards.

Orgreenic
Orgreenic Cambodia
6/9/2011 9:21:33 PM #

Truly, fantastic posting! Kudos for sharing. I do have a couple questions for you, so I'll look for your email and email them directly if that's okay.

Force Factor
Force Factor United States
6/16/2011 1:59:38 AM #


Great info, thanks to the article author. It truly is comprehensible to me now, the usefulness and significance is mind-boggling.

fddf
fddf People's Republic of China
3/31/2012 9:32:15 PM #

http://www.guccihandbagsonsaleusa.com

fake oakley sunglasses
fake oakley sunglasses People's Republic of China
4/5/2012 10:33:58 PM #

People belonging to very rich families or celebrities are very much capable to afford the branded designer sunglasses but common http://www.oakleysglassesfake.net   people with limited incomes cannot. A replica sunglass store that offers cheap alternatives to stylish and classy sunglasses is the key for them. Such a store offers a plethora of options for a customer to select.

fafafa
fafafa Slovenia
4/23/2012 2:39:42 AM #

http://www.christianlouboutinukk.org   christian louboutin
http://www.tiffanyuks.org   tiffany uk
http://www.gucciukbeltuk.org   gucci belt
http://www.frsaclouisvuittonsac.com   louis vuitton sac
http://www.chanelukoutletuks.org   chanel outlet
http://www.burberryukoutletuk.org   burberry
http://www.poloralphlaurenuko.org   ralph lauren uk

Pingbacks and trackbacks (2)+

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5