Solved

tsql cmd to strip returns

Posted on 2002-03-12
3
295 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
  • 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

735 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