路过请进,SQL字符串操作相关,在线等. select right(字段名,case when charindex(']',reverse(字段名))-1>=0 then charindex(']',reverse(字段名))-1 else 0 end)from 表名 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 --例子:declare @s varchar(100)set @s='[7]abc'select right(@s,case when charindex(']',reverse(@s))-1>=0 then charindex(']',reverse(@s))-1 else 0 end)--返回:abcset @s='fffabc'select right(@s,case when charindex(']',reverse(@s))-1>=0 then charindex(']',reverse(@s))-1 else 0 end)--返回空串 create table tb(id int,col_1 varchar(20))insert into tb values(1,'[1]aaaaaa')insert into tb values(2,'[7]bbbbbbbbbbb')insert into tb values(3,'[13]cccccccc')insert into tb values(4,'[0]ddddddd')select id,substring(col_1,charindex(']',col_1) + 1 , len(col_1)) col_1 from tbwhere charindex(']',col_1) > 0drop table tb/*id col_1 ----------- -------------------- 1 aaaaaa2 bbbbbbbbbbb3 cccccccc4 ddddddd(所影响的行数为 4 行)*/ --连续取反没有上面的简单.create table tb(id int,col_1 varchar(20))insert into tb values(1,'[1]aaaaaa')insert into tb values(2,'[7]bbbbbbbbbbb')insert into tb values(3,'[13]cccccccc')insert into tb values(4,'[0]ddddddd')select id,reverse(left(reverse(col_1),charindex(']',reverse(col_1))-1)) col_1 from tbwhere charindex(']',col_1) > 0drop table tb/*id col_1 ----------- -------------------- 1 aaaaaa2 bbbbbbbbbbb3 cccccccc4 ddddddd(所影响的行数为 4 行)*/ select id, right(col_1 , len(col_1)-charindex(']',col_1) ) as col_1 from tb oracle spool在sqlserver中可以代替吗? 我想我 Windows 7 计算机上创建一个虚拟磁盘 (.vhd)。下列过程的支持? sql 设置sa 为空密码的结果 SQL语句中的条件查询问题!!! 寻求SQL2008的解决方案 神奇的“用户 'sa' 登录失败”,期待高人解释。 关于SQLing 的拼接问题,在线等~ INTERNET上的服务器,装了MSSQL,需要配置什么吗,才能让其他服务器上的WEB程序连接到它? 时间问题 ~~~~~~~~~~~~~~~~~ 请教一小问题 跨库数据表中数据 关于上班的查询!很急
insert into tb values(1,'[1]aaaaaa')
insert into tb values(2,'[7]bbbbbbbbbbb')
insert into tb values(3,'[13]cccccccc')
insert into tb values(4,'[0]ddddddd')
select id,substring(col_1,charindex(']',col_1) + 1 , len(col_1)) col_1
from tb
where charindex(']',col_1) > 0
drop table tb/*
id col_1
----------- --------------------
1 aaaaaa
2 bbbbbbbbbbb
3 cccccccc
4 ddddddd
(所影响的行数为 4 行)
*/
insert into tb values(1,'[1]aaaaaa')
insert into tb values(2,'[7]bbbbbbbbbbb')
insert into tb values(3,'[13]cccccccc')
insert into tb values(4,'[0]ddddddd')
select id,reverse(left(reverse(col_1),charindex(']',reverse(col_1))-1)) col_1
from tb
where charindex(']',col_1) > 0
drop table tb/*
id col_1
----------- --------------------
1 aaaaaa
2 bbbbbbbbbbb
3 cccccccc
4 ddddddd
(所影响的行数为 4 行)
*/