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
 General SQL Server Forums
 New to SQL Server Programming
 split command in string

Author  Topic 

arifliminto86
Starting Member

7 Posts

Posted - 2008-02-06 : 19:40:17
hi all, i am still a newbie in sql

i got a problem with my query

for example:
-------------------------------
DECLARE @LongString VARCHAR(10)
@LongString = "Hello-Word"
------------------------
i want to change the LongString value by removing the "-" however i i need to identify if the @longString got "-" and delete it if it found how do i do that in sql

Thanks a lot guys

arifliminto86

hey001us
Posting Yak Master

185 Posts

Posted - 2008-02-06 : 20:53:32
select replace('Hello-Word','-','')

hey
Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-02-07 : 09:59:02
DECLARE @LongString VARCHAR(10)
SET @LongString = 'Hello-Word'

select replace(@LongString,'-',' ')

Note the ' ' in the replace , as opposed to '' , as this would cause 'HelloWord'


Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page

arifliminto86
Starting Member

7 Posts

Posted - 2008-02-07 : 10:18:55
thanks it solved

arifliminto86
Go to Top of Page
   

- Advertisement -