Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个像这样的字符串:(10.00+Age)power2
(10.00+Age)power2
我想将字符串更改为:power(10.00+Age,2)
power(10.00+Age,2)
sql server 2008 怎么可能?
如果字符串始终采用您显示的格式,您可以进行简单的替换
replace("(10+Age)power2",")power2",",2)")
更新
DECLARE @ans VARCHAR(200) SET @ans = 'power'+replace('(10+Age)power2',')power2',',2)')
此表达式按照描述重构您的字符串:
'power' + replace(my_column, ')power', ',') + ')'
请参阅 SQLFiddle 演示