求一条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
相关问答:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
sqlserver2005 建立的数据库,与手持pda传输数据,最近突然出现无法传递数据的问题,pda端提示的错误时outofmemoryexception,但是pda上面的容量没有问题,
sqlserver的日子上的错误如下:
日期 2010-1-25 14:45: ......
我想查询出每天数据的最大的一个值。表的格式如下
表名: hisdata
字段 编号 值 状态 时间
Id value state dattime
101 32.3 0 ......
运行后报错误如下:
错误类型:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E14)
[Microsoft][ODBC Microsoft Access Driver] 语法错误 (操作符丢失) 在查询表达式 '数学 + 4where 姓名='王静'' 中。
......
需求如下:
学院 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 ......