Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 17th, 2004, 05:43 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default truncating database data

Hi there

I've got an asp page that reads some data from a table in a database.
In one of the columns I'd like to truncate the text/content supplied from the field in the database so it only displays a certain amount of words on the page.

Is there a way to do this?

thanks

Adam
 
Old June 17th, 2004, 06:19 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

You can use substring function in SQL query to return only part of data.



Om Prakash
 
Old June 17th, 2004, 01:26 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

OK, how would I go about doing that if this is my query?

strSQL = "SELECT * FROM Categories WHERE CategoryID = 1"


thanks
 
Old June 17th, 2004, 01:34 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Adam,

Not sure, if you are using ACCESS DB or SQL server DB.

You can use SUBSTRING as om_prakash suggested, and alternately you can also use LEFT function

Select LEFT(COLUMNNAME, 20) from TABLENAME

Shows first 20 characters of that column for all rows.

Hope that helps.
Cheers!

_________________________
-Vijay G
Strive for Perfection
 
Old June 20th, 2004, 01:28 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 347
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Adam H-W
Default

thanks guys - I've got it now





Similar Threads
Thread Thread Starter Forum Replies Last Post
Datagrid truncating field values with apostrophes jrobbins ASP.NET 1.0 and 1.1 Professional 3 December 4th, 2007 08:24 PM
Truncating Transaction Log ninel SQL Server 2000 1 November 18th, 2006 01:26 PM
Truncating Transaction Log sgsandeep SQL Server 2000 2 July 11th, 2006 08:51 AM
truncating to 2 decimals msrnivas Classic ASP Components 4 July 7th, 2004 02:29 AM
truncating msrnivas .NET Web Services 2 July 7th, 2004 02:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.