Select only first N characters of a long string in SQL Server

Last Reply on Oct 22, 2012 05:52 AM By Mudassar

Posted on Oct 22, 2012 05:48 AM

hi all,

i want to select only first 50 characters from a sentence .

how to change this query?

select top 1 description from tblnews



You are viewing reply posted by: Mudassar on Oct 22, 2012 05:52 AM.
Posted on Oct 22, 2012 05:52 AM

You will have to use SUBSTRING function

declare @tmp table (data varchar(500))

insert into @tmp values('Here Mudassar Ahmed Khan has explained with an example and attached sample code, how to disable or prevent resize of HTML TextArea in browsers like Google Chrome, Mozilla FireFox and Apple Safari using CSS3')

select substring(data, 0, 50) from @tmp

I agree, here is the link: