如何在存储过程中实现插入更新数据

IT科技2025-11-05 04:21:443
如何在存储过程中实现插入更新数据
复制Create proc sp_Insert_Student      @Nochar(10),何存      @Namevarchar(20),      @Sex char(2),      @Age int,      @rtn intoutput as declare     @tmpName varchar(20),      @tmpSex char(2),      @tmpAge int     if exists(select * from Student whereNo=@No)          begin             select @tmpName=Name,@tmpSex=Sex,@tmpAge=Age from Student whereNo=@No             if ((@tmpName=@Name) and (@tmpSex=@Sex) and (@tmpAge=@Age))                  begin                     set @rtn=0   --有相同的数据,直接返回值                 end             else                 begin                     update Student setName=@Name,储过程中插入Sex=@Sex,Age=@Age whereNo=@No                     set @rtn=2   --有主键相同的站群服务器数据,进行更新处理                 end         end     else         begin             insertinto Student values(@No,实现数据@Name,@Sex,@Age)              set @rtn=1    --没有相同的服务器托管数据,更新进行插入处理         end 1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.22.23.24.25.26.27.28.29.30.服务器租用
本文地址:http://www.bzuk.cn/html/23f7899898.html
版权声明

本文仅代表作者观点,不代表本站立场。
本文系作者授权发表,未经许可,不得转载。

全站热门

提升你的打字速度(解锁高效输入,轻松应对键盘操作挑战)

牛轧糖信号(以甜蜜牛轧糖引爆味蕾,探寻其独特信号)

华为荣耀8待机表现如何?(探究华为荣耀8待机性能及相关功能特点)

ISO镜像装系统教程(使用ISO镜像安装系统,省时省力又便捷!)

电脑wis系统安装教程(电脑wis系统安装详解,助你提升工作效率与便捷性)

三星i8268手机的优势与劣势剖析(一部性能卓越但存在缺陷的智能手机)

酷睿i5处理器(探索酷睿i5处理器的强大功能与先进技术)

探索oppo耳机的音质和功能(领先科技的oppo耳机给您带来无与伦比的音乐体验)

友情链接

滇ICP备2023006006号-33