Solved

tsql cmd to strip returns

Posted on 2002-03-12
3
292 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:
ScottPletcher earned 75 total points
Comment Utility
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
Comment Utility
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:ScottPletcher
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how the fundamental information of how to create a table.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now