如果都是“每隔1分钟就有一条新的数据添加进来
直接查就可以了---测试数据---
if object_id('[tb]') is not null drop table [tb]
go
create table [tb]([time] datetime,[bookname] varchar(14),[price] numeric(4,2),[net] numeric(4,2))
insert [tb]
select '2009-02-02 16:46','java100例',25.36,null union all
select '2009-02-02 16:47','net100例',24.86,null union all
select '2009-02-02 16:48','javascript详解',23.12,null
 
---查询---
select [time],bookname,price,
  net=price-isnull((select price from tb where [time]=dateadd(mi,-1,t.[time])),price)
from tb t---结果---
time                                                   bookname       price  net     
------------------------------------------------------ -------------- ------ ------- 
2009-02-02 16:46:00.000                                java100例       25.36  .00
2009-02-02 16:47:00.000                                net100例        24.86  -.50
2009-02-02 16:48:00.000                                javascript详解   23.12  -1.74(所影响的行数为 3 行)

解决方案 »

  1.   

    -- 建立测试数据
    create table tb(time datetime,bookname nvarchar(100),price decimal(10,2), net decimal(10,2))
    GO
    insert into tb
    select '2009-02-02 16:46' ,   'java100例'     ,   25.36     , null UNION ALL
    select '2009-02-02 16:47',    'net100例'      ,    24.86    ,  null UNION ALL
    select '2009-02-02 16:48'  ,  'javascript详解'  ,  23.12    ,  null 
    --更新第一行
    UPDATE tb SET net=0 where time='2009-02-02 16:46'
    --定期更新使用的语句
    UPDATE tb 
    SET net= price-(select a.price from tb a where datediff(minute,a.time,b.time)=1)
    FROM tb b
    where net is null
    --测试结果
    select * from tb
    time                      bookname         price        net          
    ------------------------ ----------- ------------ ------------ 
    2009-02-02 16:46:00.000     java100例          25.36        .00
    2009-02-02 16:47:00.000     net100例           24.86        -.50
    2009-02-02 16:48:00.000     javascript详解    23.12        -1.74(3 row(s) affected)
      

  2.   

    定时作业的制定 企业管理器 
    --管理 
    --SQL Server代理 
    --右键作业 
    --新建作业 
    --"常规"项中输入作业名称 
    --"步骤"项 
    --新建 
    --"步骤名"中输入步骤名 
    --"类型"中选择"Transact-SQL 脚本(TSQL)" 
    --"数据库"选择执行命令的数据库 
    --"命令"中输入要执行的语句: 
                          EXEC 存储过程名 ... --该存储过程用于创建表 --确定 
    --"调度"项 
    --新建调度 
    --"名称"中输入调度名称 
    --"调度类型"中选择你的作业执行安排 
    --如果选择"反复出现" 
    --点"更改"来设置你的时间安排  
    然后将SQL Agent服务启动,并设置为自动启动,否则你的作业不会被执行 设置方法: 
    我的电脑--控制面板--管理工具--服务--右键 SQLSERVERAGENT--属性--启动类型--选择"自动启动"--确定.