MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 29th, 2004, 06:22 AM
HostingStar HostingStar is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 8 HostingStar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 19 sec
Reputation Power: 0
Retrieve the 1st 15 words of a field

Hello,

i need a select statement that will retrieve only the 1st 15 words of a text field.


is it possible?

Thanks.

Reply With Quote
  #2  
Old November 29th, 2004, 02:04 PM
fbraun fbraun is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Posts: 307 fbraun User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 h 4 m
Reputation Power: 0
No, not possible. Your select statement can only pull the whole field. You'll have to use your server side scripting to parse out the first 15 characters. Such as:

varShortened = left(RS("thisField"), 15)

Reply With Quote
  #3  
Old November 29th, 2004, 02:50 PM
Username=NULL Username=NULL is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: TX
Posts: 249 Username=NULL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 7 h 6 m 42 sec
Reputation Power: 5
Send a message via Yahoo to Username=NULL
well not totally true. The select can pull out the 1st 15 chars from a field once it's in the table, but not from the text field that resides up front...it's up to your server script to get it to the dB first. fBraun, this may be more or less what you're getting @?

Reply With Quote
  #4  
Old November 29th, 2004, 04:34 PM
HostingStar HostingStar is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Posts: 8 HostingStar User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 19 sec
Reputation Power: 0
I think i found a solution.

SELECT fieldID, Title LEFT(field, CHARINDEX(" ", field, 200))

It gets the 1st 200 caracters, and if it is not a space it goes until finding a space.

Thanks for your reply

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Retrieve the 1st 15 words of a field


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT