| 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) > 0begin select @var = replace(@var, ' ', ' ')endselect @varGo with the flow & have fun! Else fight the flow |
 |
|
|
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." |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2005-08-16 : 13:05:23
|
i saw you do that once before.... didn't remember it... thanxGo with the flow & have fun! Else fight the flow |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-08-17 : 01:12:09
|
| WellThere is an extra quotationThe correct one isSelect @var, Replace(Replace(Replace(@var,' ',' þ'),'þ ',''),'þ','')Corey, how did you type that special p?MadhivananFailing to plan is Planning to fail |
 |
|
|
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,' ','') |
 |
|
|
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 |
 |
|
|
cbeganesh
Posting Yak Master
105 Posts |
Posted - 2005-08-17 : 12:11:40
|
| im sorry, i thought SQUEEZE function is to remove all spaces |
 |
|
|
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 0254Corey 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." |
 |
|
|
|