Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
igorblackbelt
Constraint Violating Yak Guru
407 Posts |
Posted - 2006-04-14 : 09:59:01
|
| Is there a more efficient way of doing this ?REPLACE(REPLACE(REPLACE(DESCRIPTION, ' ', ''), ',', ''), '.', '')---Thanks!Igor. |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-04-14 : 10:31:44
|
| You want to remove all spaces from DESCRIPTION? In other words, there would be no spaces between words?CODO ERGO SUM |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
|
|
igorblackbelt
Constraint Violating Yak Guru
407 Posts |
Posted - 2006-04-17 : 14:18:21
|
| Michael -On the code that I posted, I'm removing spaces, commas and dots from a column in a table.Seventh -Thanks for the link, let me take a look.---Thanks!Igor. |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-04-17 : 14:35:41
|
quote: Originally posted by igorblackbelt Is there a more efficient way of doing this ?REPLACE(REPLACE(REPLACE(DESCRIPTION, ' ', ''), ',', ''), '.', '')---Thanks!Igor.
What you have posted is efficient, although it may not be pretty. Using UDFs will be a little bit less efficient but prettier. So it depends what you want.Tara Kizeraka tduggan |
 |
|
|
Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)
7020 Posts |
Posted - 2006-04-17 : 15:16:55
|
quote: Originally posted by igorblackbelt Michael -On the code that I posted, I'm removing spaces, commas and dots from a column in a table...
I understand what the code is doing. I just wanted to confirm you really want to have no spaces between the words in your description (see below). Is seems very unusual.select MyNewDescription = replace(replace(replace(DESCRIPTION, ' ', ''), ',', ''), '.', '')from ( select DESCRIPTION = 'This is a description' ) aResults:MyNewDescription----------------------------------------Thisisadescription(1 row(s) affected) CODO ERGO SUM |
 |
|
|
igorblackbelt
Constraint Violating Yak Guru
407 Posts |
Posted - 2006-04-19 : 11:28:13
|
| Yeah, sounds weird, but that's right, the DESCRIPTION in reality is what they have for the client's name, it's weird to explain, but as you know, there's a business logic behind it. The idea is use the Client name to pass as a variable parameter on the DTS package to build the reports for each client, and use the client name without the spaces as the Report Name and send that out automatically.As Tara said, it's is doing it's job, but doesn't look pretty when looking at the code.Thanks for the help all, I really appreciate this.---Thanks!Igor. |
 |
|
|
|
|
|
|
|