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
 SQL Server Development (2000)
 SQUEEZE

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-08-16 : 08:00:04
amar writes " pl help me
how to implment SQUEEZE like functionality in sql server
in scripting we write squeeze function
what is sql server equivalent for squeeze function

one more think how to identify current database in store proc


"

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-16 : 08:53:34
here ya go...

declare @var varchar(100)
set @var = 'fasf gdsfsda ewffea '

while charindex(' ', @var) > 0
begin
select @var = replace(@var, ' ', ' ')
end

select @var


Go with the flow & have fun! Else fight the flow
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-08-16 : 12:51:06
spirit you don't actually need a loop for this:
-- Replace all spaces (' ') with a space and an absract character (say ' þ')
-- Replace all abstract and space combinations ('þ ') with empty string ('')
-- Replace all abstracts ('þ') with empty string ('')



Declare @var varchar(100)
Set @var = 'fasf gdsfsda ewffea '

Select @var, Replace(Replace(Replace(@var,' ','' þ'),'þ ',''),'þ','')


can't test, but i think that works (not at home - in .NET training )

Corey

Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now."
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-16 : 13:05:23
i saw you do that once before.... didn't remember it... thanx

Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-17 : 01:12:09
Well
There is an extra quotation
The correct one is
Select @var, Replace(Replace(Replace(@var,' ',' þ'),'þ ',''),'þ','')

Corey, how did you type that special p?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

cbeganesh
Posting Yak Master

105 Posts

Posted - 2005-08-17 : 10:55:28
declare @var varchar(100)
set @var = 'fasf gdsfsda ewffea '
select replace(@var,' ','')
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-08-17 : 10:58:24
why would you want to get rid of all of the spaces, cbeganesh?

that's not what the squeeze function does as far as i know....

Go with the flow & have fun! Else fight the flow
Go to Top of Page

cbeganesh
Posting Yak Master

105 Posts

Posted - 2005-08-17 : 12:11:40
im sorry, i thought SQUEEZE function is to remove all spaces
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2005-08-17 : 15:52:46
sorry about the extra '...

to type þ: hold-alt and key 0254

Corey

Co-worker on The Wizard of Oz "...those three midgets that came out and danced, the freaked me out when I was little. But they are ok now."
Go to Top of Page
   

- Advertisement -