Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsDatabasesMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old July 8th, 2008, 10:16 PM
trademind trademind is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2008
Posts: 1 trademind User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 13 m 21 sec
Reputation Power: 0
Replace in Ntext Field

Hi All,

i am having difficulties to find a function replace some text into and NTEXT field of a SQLServer database.

I need to remove a string that always come at the end of each records and is a fixed lenght, about 20 char.

maybe can be done in 2 ways, a search and replace or a trm of the final part of the string.

Anyone can suggest a piece of code to run?

Thanks!

Reply With Quote
  #2  
Old July 9th, 2008, 09:16 AM
dykebert's Avatar
dykebert dykebert is offline
Contributing User
Click here for more information. Click here for more information
 
Join Date: Apr 2008
Posts: 349 dykebert User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 Days 11 h 7 m 47 sec
Reputation Power: 1
You can do this with a query that would look something like this. (Note: <name> indicates that you need to replace this with the appropriate name from your database.)

Update <tblName> SET <fieldName> = LEFT(<fieldName>,len(<fieldName>) - <20>)

If some records will have the end text that needs to be removed and some won't you will to use a WHERE clause to filter them something like this:

Update <tblName> SET <fieldName> = LEFT(<fieldName>,len(<fieldName>) - <20>)
WHERE RIGHT(<fieldName>, <3>) = "foo"

Enjoy!

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsDatabasesMicrosoft SQL Server > Replace in Ntext 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 6 hosted by Hostway
Stay green...Green IT