sql預存程序 select rowscount然後再insert,預存程序rowscount

來源:互聯網
上載者:User

sql預存程序 select rowscount然後再insert,預存程序rowscount


       截至上一篇部落格已經快一年半沒寫了,確實這一年半裡確實沒啥有多少關於技術的東西可寫,現在利用這個項目的機會再把部落格拾起來吧,也為了防止以後老年癡呆了沒啥好回憶的。

內容如題。



USE [VSMMS]GO/****** Object:  StoredProcedure [dbo].[proc_PublicEngageClass_INSERT_NoSort]    Script Date: 03/25/2015 16:42:06 ******/SET ANSI_NULLS ONGOSET QUOTED_IDENTIFIER ONGOALTER PROCEDURE [dbo].[proc_PublicEngageClass_INSERT_NoSort]@PEC_Fid int,@PEC_Name varchar(200)ASdeclare @sql nvarchar(max),@count intset @sql='select @c=count(1) from [PublicEngageClass] where [PEC_Fid]=0'exec sp_executesql @sql,N'@c int output',@count outputselect  @count  BEGIN    SET NOCOUNT ON;INSERT INTO [PublicEngageClass]([PEC_Fid],[PEC_Name],[PEC_Sort])VALUES (@PEC_Fid,@PEC_Name,@count+1)END



相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.