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
 Select Replace help please

Author  Topic 

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2006-06-27 : 08:14:55
hi,

SELECT @SQL = 'select REPLACE('+@t_name+','/','-')'
Exec (@SQL)

i have a @t_name having names like this EUR/USD and i wanna replace it like this EUR-USD but above statement did not do it. Would you please help?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-06-27 : 08:16:40
select @t_name = REPLACE(@t_name, '/', '-')


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

raysefo
Constraint Violating Yak Guru

260 Posts

Posted - 2006-06-27 : 08:32:41
thanks so much
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-27 : 08:47:01
quote:
Originally posted by raysefo

hi,

SELECT @SQL = 'select REPLACE('+@t_name+','/','-')'
Exec (@SQL)

i have a @t_name having names like this EUR/USD and i wanna replace it like this EUR-USD but above statement did not do it. Would you please help?


If you use Dynamic SQL, then for every single quote you need to double them.

SELECT @SQL = 'select REPLACE('''+@t_name+''',''/'',''-'')'

Avoid Dynamic SQL as much as possible


Madhivanan

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

- Advertisement -