SQL stored procedure select rowscount and then insert, stored procedure rowscount
The previous blog has not been written for nearly a year and a half. It is true that there are not many technical things to be written in the past year and a half. Now let's use this project to pick up the blog, to prevent future Alzheimer's disease, too.
The content is as follows.
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