存储过程在表中添加两列 [英] Stored Procedure to add two column in a table

查看:68
本文介绍了存储过程在表中添加两列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Sql-server 2005中有表,我想在两列(加法,乘法)上执行数学运算并将结果保存在第三列.

解决方案

是:

  USE  [正在测试]
转到
设置  ANSI_NULLS  打开
转到
设置  QUOTED_IDENTIFIER  >打开
转到
创建 过程 [proc_AddEmUp]
 AS 
更新 myTable  SET  sumColumn = firstColumn + SecondColumn 


i have table in the Sql-server 2005, i want to perform math operation on two column(ex addition,multiplication) and save the result in the 3 rd column.
is it possible to do with stored procedure.

解决方案

Yes:

USE [Testing]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [proc_AddEmUp] 
AS
UPDATE myTable SET sumColumn=firstColumn+SecondColumn


这篇关于存储过程在表中添加两列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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