sql server存储过程(查询) [英] sql server Stored Procedure (query)

查看:95
本文介绍了sql server存储过程(查询)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的,

我遇到了查询问题。

我有桌面名称促销(sale_id,余额,customer_id)

数据类似as



Dear,
I have faced a query problem.
I have table name sale(sale_id,balance,customer_id)
Data like as

sale_id,                balance,                         customer_id
1       ,                 500   ,                             2
2       ,                 600   ,                             2
3       ,                 4000  ,                             2
4       ,                 3000  ,                             3



现在我需要在sp中查询

我有金额1000& customer_id 2

提示:

更新表列余额,直到金额为1000,其中customer_id = 2



需要检查金额1000然后根据金额更新列。

我有点困境,请帮助我。

提前付款

Mahmud

软件工程师


now i need to query in sp like
I have amount 1000 & customer_id 2
hints:
update table column balance like until amount 1000 where customer_id=2

need checking amount 1000 then update column according amount.
I am bit dilemma,help me please.
Thanks in advance
Mahmud
Software Engineer

推荐答案

ALTER PROCEDURE StoredProcedureName



@customer_id smallint,

@balance smallint







AS

SET NOCOUNT ON



更新销售

SET余额= @balance

WHERE(customer_id = @customer_id)



RETURN
ALTER PROCEDURE StoredProcedureName
(
@customer_id smallint,
@balance smallint

)

AS
SET NOCOUNT ON

UPDATE sale
SET balance = @balance
WHERE (customer_id = @customer_id)

RETURN


这篇关于sql server存储过程(查询)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆