易截截图软件、单文件、免安装、纯绿色、仅160KB

求一条sql语句 - MS-SQL Server / 基础类

cFilePath 字段中有如下值
lcz\0821\194712_01.jpg
lcz\0821\194712_06.jpg
.....................


现在要以这个字段的值去修改 flag 字段的值,cFilePath 字段满足条件 lcz\0821\194712,即“_”前内容相同时

环境SQL Server 2000

SQL code:
cFilePath like 'lcz\0821\194712%'


update tb set flag = left(cFilePath , charindex('-',cFilePath) - 1) where charindex('-',cFilePath) > 0

SQL code:
update tb set flag=right(col,charindex('_',reverse(col))-1)


SQL code:
create table tb(cFilePath varchar(30),flag varchar(30))
insert into tb values('lcz\0821\194712_01.jpg',null)
insert into tb values('lcz\0821\194712_06.jpg',null)
go

update tb set flag = left(cFilePath , charindex('_',cFilePath) - 1) where charindex('_',cFilePath) > 0

select * from tb

drop table tb

/*
cFilePath flag
------------------------------ ------------------------------
lcz\0821\194712_01.jpg lcz\0821\194712
lcz\0821\194712_06.jpg lcz\0821\194712

(所影响的行数为 2 行)
*/


SQL code



Code highl


相关问答:

sql小小的疑问 - .NET技术 / C#

可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......

MS SQL作业问题 - MS-SQL Server / 应用实例

如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP

参考:http://hi.baidu.com/toiota ......

求一个SQL语句 - MS-SQL Server / 基础类

字段1,字段2.....字段N,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
想要的结果是:
1,Na ......

SQL语句问题 - MS-SQL Server / 疑难问题

请教高手:
 以下是数据库中的三条记录,英文为字段名称  
  id planname TaskBeginTime Status
329 2010年03 ......

sql 问题 - MS-SQL Server / 基础类

需求如下:
学院 academy(aid,aname)
班级 class(cid,cname,aid)
学生 stu(sid,sname,aid,cid)
住宿区 region(rid,rname)
宿舍楼 build(bid,rid,bnote) bnote是‘男’/‘女’
宿舍 dorm(did,rid,bid,bedn ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号