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

sql 更新某一列 - MS-SQL Server / 基础类

数据库中有一列,里面的值 或空或有值。
想更新这一列,将空值的部分添加数值,使更新后的值与原来的值不重复,最好是依次增长的顺序
可以试试用identity函数

SQL code:
declare @i int
set @i=1
update tb set @i=@i+1,col=ltrim(@i) where col is null


管理员很强大!!

学习了

引用
SQL code
declare @i int
set @i=1
update tb set @i=@i+1,col=ltrim(@i) where col is null

不错

引用
SQL code
declare @i int
set @i=1
update tb set @i=@i+1,col=ltrim(@i) where col is null

呵呵

引用
SQL code
declare @i int
set @i=1
update tb set @i=@i+1,col=ltrim(@i) where col is null

!!!!!

谢谢大家的跟帖,2楼 果然很厉害。
谢谢,结贴,顶贴者都有份


相关问答:

求一SQL - MS-SQL Server / 基础类

tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......

请教SQLSERVER的两个问题 - MS-SQL Server / 疑难问题

1。怎样使xp_cmdshell能完整输出超过255个字符的字符串。
2。select 时,检索速度是与from后的 TABLE顺序有关,还是与where条件的顺序有关(TABLE数据多少 )
在系统属性设定里有个选项,可以修改单字段输出字数限制. ......

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 ......

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

现在有一个部门表dept(部门名称,部门号。。)有一个人员表emp(姓名,人员编号,职位,薪资,部门)
emp表中的内容是这样的:
a 1 工程师 3000 软件部
b 2 普通员工 2000 硬件部
c 3 工程师 4000 硬件部
d ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号