首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

SQL返回ID有关问题

2012-04-06 
SQL返回ID问题SQL codecreate proc DingDan_Add(@VIPID varchar(50),@TaoXiID int,@ShopID int,@TaoXiText

SQL返回ID问题

SQL code
create proc DingDan_Add(@VIPID varchar(50),@TaoXiID int,@ShopID int,@TaoXiText nvarchar(1000),@Time1 varchar(50),@Time2 varchar(50),@Time3 varchar(50),@BeiZhu nvarchar(1000),@DD_Type int,@DD_PayType int,@DD_Money float,@End int,@Give int,@ZengSongID int,--以下为Pay表数据@Pay_Money float,@InTime datetime,@JingShou int,@P1 int,@P2 int,@P3 int,@P4 int,@Pay_Type int,@Pay_PayType int)asDECLARE @Error_DingDan int,@Error_Pay int,@Error_EditVIPScore int,@Error_ZengSong int,@Error_ZengSongDingDan int,@DingDanID int,@ZengSongDingDanID int,@ZengSongTaoXiText nvarchar(1000)begin transaction DingDaninsert DingDan values(@VIPID,@TaoXiID,@ShopID,@TaoXiText,@Time1,@Time2,@Time3,@BeiZhu,@DD_Type,@DD_PayType,@DD_Money,@End,@Give)Set @DingDanID=@@identitySet @Error_DingDan=@@Errorif(@ZengSongID>0)Set @ZengSongTaoXiText=(select T_Text from TaoXi where T_ID=@ZengSongID)if(@ZengSongID>0)insert DingDan values(@VIPID,@ZengSongID,@ShopID,@ZengSongTaoXiText,'','','','',@DD_Type,0,0,@End,0)Set @ZengSongDingDanID=@@identitySet @Error_ZengSongDingDan=@@Errorif(@ZengSongID>0)insert ZengSong values(@DingDanID,@ZengSongDingDanID)Set @Error_ZengSong=@@Errorinsert Pay values(@DingDanID,@Pay_Money,@InTime,@JingShou,@P1,@P2,@P3,@P4,@Pay_Type,@Pay_PayType)Set @Error_Pay=@@Errorupdate VIP Set V_Score=V_Score+@Pay_Money where V_ID=@VIPIDSet @Error_EditVIPScore=@@Errorif @Error_DingDan>0 or @Error_Pay>0 or @Error_EditVIPScore>0 or @Error_ZengSong>0 or @Error_ZengSongDingDan>0beginRollback transaction DingDanendelsecommit transaction DingDango


请问,我现在程序执行这个存储过程,我怎么才能在程序里面得到@DingDanID的值?以前都是一条sql语句@@identity得到的

[解决办法]
存储过程里面的最后加上select @DingDanID

热点排行