Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Limit characters in ntext field

Author  Topic 

Dejan
Starting Member

14 Posts

Posted - 2008-10-26 : 08:13:25
Hello,
I have Stored procedure to call last 3 news in my table:

ALTER PROCEDURE dbo.top3News

@id_lang int

AS
SELECT TOP 3 id_news, id_lang, subject, newstext, date
FROM news
WHERE (id_lang = @id_lang)
ORDER BY id_news DESC
RETURN

newstext field is ntext. I'd like to show only first 500 charachters of the value and add '...' at the end of the text.

Thanks for the help

Dejan
Starting Member

14 Posts

Posted - 2008-10-26 : 13:52:21
ALTER PROCEDURE dbo.top3News

@id_lang int

AS
SELECT TOP 3 id_news, id_lang, subject, date substring (newstext,1,450) as text,
FROM news
WHERE (id_lang = @id_lang)
ORDER BY id_news DESC
RETURN

This is the solution
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-26 : 13:52:39
quote:
Originally posted by Dejan

Hello,
I have Stored procedure to call last 3 news in my table:

ALTER PROCEDURE dbo.top3News

@id_lang int

AS
SELECT TOP 3 id_news, id_lang, subject, SUBSTRING(newstext,1,500) + '...' AS newstext, date
FROM news
WHERE (id_lang = @id_lang)
ORDER BY id_news DESC
RETURN


newstext field is ntext. I'd like to show only first 500 charachters of the value and add '...' at the end of the text.

Thanks for the help



modify as above.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-26 : 13:59:18
Go to Top of Page
   

- Advertisement -