易截截图软件、单文件、免安装、纯绿色、仅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楼 果然很厉害。
谢谢,结贴,顶贴者都有份


相关问答:

数据以xml格式返回 - MS-SQL Server / 应用实例

从数据库中查询一张表的数据
select 部门,姓名 from tb
如何才能生成下面的xml格式
XML code:
<folder state="unchecked" label="全部">
   <folder state="unchecked&qu ......

关于SQL语句OR的问题 - Oracle / 高级技术

通过NAME字段条件查询一个数据表,假设我有100个姓名,有以下两个方法,
方法1:
把100个Name 组成一个SQL语句,比如 Select * from tmp_table where Name='张三' or Name ='李四' Or ...Or Name='第一百个姓名'
......

sql语句问题 - Java / Web 开发

select o_customer,o_price from orders having o_price >=avg(o_price)
select o_customer,o_price from orders where o_price >=(select avg(o_price) from orders)
我感觉没有区别啊,怎么在mysql会有 ......

C# SQL 的UPDATETEXT 问题 - .NET技术 / C#

A表 有两个字段 
  id 唯一数字域
  InfoTxt text 类型
 我现在要把 id 不是14 的所有 InfoTxt字段 文本后面 都加上 'aaa' 
按下面执行下来 只有表最后一行加上了 'aaa' ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号