Solved

tsql cmd to strip returns

Posted on 2002-03-12
3
297 Views
Last Modified: 2006-11-17
I need the a tsql command that will strip of instances of a _trailing_ carragereturn/linefeed from a given field in a table.

thankx
--steve...
0
Comment
Question by:juststeve
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 75 total points
ID: 6858061
Try one of these:

To UPDATE the column:
UPDATE tablename
SET column = LEFT(column,LEN(column) - 2)
WHERE RIGHT(column,2) = CHAR(13)+CHAR(10)

To SELECT the column:
SELECT CASE RIGHT(column,2) = CHAR(13)+CHAR(10) THEN LEFT(column,LEN(column) - 2) ELSE column END
FROM tablename
0
 

Author Comment

by:juststeve
ID: 6858249
thankx Scott....it appears to do what I want. The bit about the 'To SELECT the column:'... that's just so I can see what I'm going to update before I do so?
0
 
LVL 69

Expert Comment

by:Scott Pletcher
ID: 6858320
Exactly; most people prefer to see what an update's going to do before they actually issue it.  Normally I would list the old and the new values but I didn't think you'd be able to see any difference in this case :-).
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question