求存储过程!该怎么解决

求存储过程!!
有一张表,表中有SN(序号),status(状态), amount(数量),aceptamount(最终数量),data(日期),要通过上传SN号实现amount的值加1,
同一个SN号被上传几次,amount的值就增加几次,当amount超过aceptamount不允许上传
必须在amount<aceptamount,data<2014.03.31
status ="sleep"的条件下,这样的存储过程要怎么写? 求好心人帮忙啊!
(就剩20分了,日后有分一定加倍报答!)
------解决方案--------------------
是这样吗:
 --如果能找到记录,说明还可以上传
 if exists(select 1 
           from tb
           where amount+1<aceptamount and data<'2014.03.31' and status ="sleep"
           and sn = @sn
           )
    update tb
    set amount = amount+1
    where sn = @sn

------解决方案--------------------
update tb
    set amount = amount+1
    where amount+1<aceptamount and data<'2014.03.31' and status ="sleep"
           and sn = @sn
SELECT @@ROWCOUNT
------解决方案--------------------
引用:
Quote: 引用:

是这样吗:
 --如果能找到记录,说明还可以上传
 if exists(select 1 
           from tb
           where amount+1<aceptamount and data<'2014.03.31' and status ="sleep"
           and sn = @sn
           )
    update tb
    set amount = amount+1
    where sn = @sn
 
可是sn要从上传的文件中取,这样写可以吗?


sn是上传文件中的,那得把sn提取出来,传入到存储过程中
------解决方案--------------------
引用:
Quote: 引用:

Quote: 引用:

Quote: 引用:

是这样吗:
 --如果能找到记录,说明还可以上传
 if exists(select 1 
           from tb
           where amount+1<aceptamount and data<'2014.03.31' and status ="sleep"
           and sn = @sn
           )
    update tb
    set amount = amount+1
    where sn = @sn
 
可是sn要从上传的文件中取,这样写可以吗?


sn是上传文件中的,那得把sn提取出来,传入到存储过程中



我不知道该怎么提取啊,求代码求存储过程!该怎么解决


CREATE PROC test(@sn nvarchar(20))
AS 
BEGIN
放上面代码
END

------解决方案--------------------
引用:
有没有人啊?
你上面说的不知道怎么提取 是什么意思 是返回更新后的数据还是 程序得到结果?
------解决方案--------------------
没弄过上传文件~    
先把文件里数据导入到一个表里 然后做个小程序读取所有数据 然后循环插入到最终表里吧(循环执行上面的插入 改改参数和语句 要是不存在新增)