数据库中有这样一些数据
description
Silver Pendant with RS5.0-LZ/CZ(SILVER$10.51-11.50/OUNCE) and WP ( PO#1733,UCC060868)
Silver Earring with PS BZ/CZ($11.51--$12.50/OZ) and WP(U060 SZ064183)PO#VALE 152
Silver Pendant with CZ(WP)/GP and RP (PO#HK ORDER 23-09,UCC060906)
16# Silver Ring with CU CTL/CZ(SILVER$11.51-12.50/OZ) and WP ( PO#2020,UCC060990)
数据类似如上
我想要通过select语句达到一种如下效果
description
Silver Pendant with RS5.0-LZ/CZ(SILVER$10.51-11.50/OUNCE) and WP
Silver Earring with PS BZ/CZ($11.51--$12.50/OZ) and WP
Silver Pendant with CZ(WP)/GP and RP
16# Silver Ring with CU CTL/CZ(SILVER$11.51-12.50/OZ) and WP
在sqlserver2000中我的这个select语句应该怎么去写它,请教中............
从右边开始取,当遇到第一个(符号的时候结束
description
Silver Pendant with RS5.0-LZ/CZ(SILVER$10.51-11.50/OUNCE) and WP ( PO#1733,UCC060868)
Silver Earring with PS BZ/CZ($11.51--$12.50/OZ) and WP(U060 SZ064183)PO#VALE 152
Silver Pendant with CZ(WP)/GP and RP (PO#HK ORDER 23-09,UCC060906)
16# Silver Ring with CU CTL/CZ(SILVER$11.51-12.50/OZ) and WP ( PO#2020,UCC060990)
数据类似如上
我想要通过select语句达到一种如下效果
description
Silver Pendant with RS5.0-LZ/CZ(SILVER$10.51-11.50/OUNCE) and WP
Silver Earring with PS BZ/CZ($11.51--$12.50/OZ) and WP
Silver Pendant with CZ(WP)/GP and RP
16# Silver Ring with CU CTL/CZ(SILVER$11.51-12.50/OZ) and WP
在sqlserver2000中我的这个select语句应该怎么去写它,请教中............
从右边开始取,当遇到第一个(符号的时候结束
insert @t
select 'Silver Pendant with RS5.0-LZ/CZ(SILVER$10.51-11.50/OUNCE) and WP ( PO#1733,UCC060868)' union all
select 'Silver Earring with PS BZ/CZ($11.51--$12.50/OZ) and WP(U060 SZ064183)PO#VALE 152' union all
select 'Silver Pendant with CZ(WP)/GP and RP (PO#HK ORDER 23-09,UCC060906)]' union all
select '16# Silver Ring with CU CTL/CZ(SILVER$11.51-12.50/OZ) and WP ( PO#2020,UCC060990)'select reverse(substring(reverse([description]),charindex('(',reverse([description])) + 1,len([description]) - charindex('(',reverse([description])) + 1))
from @t/*结果
Silver Pendant with RS5.0-LZ/CZ(SILVER$10.51-11.50/OUNCE) and WP
Silver Earring with PS BZ/CZ($11.51--$12.50/OZ) and WP
Silver Pendant with CZ(WP)/GP and RP
16# Silver Ring with CU CTL/CZ(SILVER$11.51-12.50/OZ) and WP
*/
insert into @t select
'Silver Pendant with RS5.0-LZ/CZ(SILVER$10.51-11.50/OUNCE) and WP ( PO#1733,UCC060868)' union all select
'Silver Earring with PS BZ/CZ($11.51--$12.50/OZ) and WP(U060 SZ064183)PO#VALE 152' union all select
'Silver Pendant with CZ(WP)/GP and RP (PO#HK ORDER 23-09,UCC060906)' union all select
'16# Silver Ring with CU CTL/CZ(SILVER$11.51-12.50/OZ) and WP ( PO#2020,UCC060990)'
select reverse(right(reverse(lStr),len(lStr)-charindex('(',reverse(lStr)))) from @t
from @t
declare @t table([description] varchar(200))
insert @t
select 'Silver Pendant with RS5.0-LZ/CZ(SILVER$10.51-11.50/OUNCE) and WP ( PO#1733,UCC060868)' union all
select 'Silver Earring with PS BZ/CZ($11.51--$12.50/OZ) and WP(U060 SZ064183)PO#VALE 152' union all
select 'Silver Pendant with CZ(WP)/GP and RP (PO#HK ORDER 23-09,UCC060906)]' union all
select '16# Silver Ring with CU CTL/CZ(SILVER$11.51-12.50/OZ) and WP ( PO#2020,UCC060990)'
select reverse(stuff(reverse([description]),1,charindex('(',reverse([description]),1),'')) from @t