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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Replace

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
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2006-04-14 : 10:37:49
This might be applicable...

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=56713

Corey

Co-worker on children "...when I have children, I'm going to beat them. Not because their bad, but becuase I think it would be fun ..."
Go to Top of Page

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.
Go to Top of Page

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 Kizer
aka tduggan
Go to Top of Page

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' ) a


Results:

MyNewDescription
----------------------------------------
Thisisadescription

(1 row(s) affected)



CODO ERGO SUM
Go to Top of Page

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.
Go to Top of Page
   

- Advertisement -