Создайте следующую хранимую процедуру, но @tagID
не увеличивается для более чем 10 последовательных из 1 - пожалуйста, помогите.
CREATE PROCEDURE [dbo].[bulk_employee]
@active BIT,
@FNAME NVARCHAR(50),
@DOB DATE,
@DOJ DATE,
@GENDER NVARCHAR(10),
@FATHER_NAME NVARCHAR(50) = NULL,
@AADHAR NVARCHAR(14),
@ESIC NVARCHAR(10) = NULL,
@UAN NVARCHAR(10) = NULL,
@SALARY INT,
@BRANCH INT,
@DIVISION INT,
@USER INT
AS
BEGIN
DECLARE @TagID INT;
SELECT @TagID = COALESCE((SELECT MAX(Emp_ID) + 1 FROM EmployeeP1), 1)
INSERT INTO EmployeeP1 (isActive, Emp_ID, FirstName, BirthDate, JoiningDate, Gender, FatherName, aadharnumber, ESIC, UAN, SalaryID, DivisionID, BranchID, AccessBy, LastUsed)
VALUES ('0', @TagID, @FNAME, @DOB, @DOJ, @GENDER, @FATHER_NAME, @AADHAR, @ESIC, @UAN, @SALARY, @DIVISION, @BRANCH, @USER, CURRENT_TIMESTAMP)
END
Структура EmployeeP1
CREATE TABLE [dbo].[EmployeeP1]
(
[EmployeeID] [int] IDENTITY(1,1) NOT NULL,
[Emp_ID] [nvarchar](10) NULL,
[isActive] [bit] NULL,
[FirstName] [nvarchar](50) NOT NULL,
[LastName] [nvarchar](50) NULL,
[BirthDate] [date] NOT NULL,
[Gender] [nvarchar](10) NOT NULL,
[FatherName] [nvarchar](50) NOT NULL,
[MotherName] [nvarchar](50) NULL,
[Address1] [nvarchar](50) NULL,
[Address2] [nvarchar](50) NULL,
[Address3] [nvarchar](50) NULL,
[Pin_Code] [numeric](6, 0) NULL,
[DistrictID] [int] NULL,
[StateID] [int] NULL,
[Mobile] [nvarchar](10) NULL,
[Mobile2] [nvarchar](10) NULL,
[Email] [nvarchar](50) NULL,
[AccountName] [nvarchar](50) NULL,
[BankAccount] [nvarchar](30) NULL,
[IfscCode] [nvarchar](11) NULL,
[PermanentAccount] [nvarchar](10) NULL,
[AadharNumber] [nvarchar](14) NULL,
[JoiningDate] [date] NOT NULL,
[ESIC] [nchar](12) NULL,
[Esic_Joining_Date] [date] NULL,
[UAN] [nchar](12) NULL,
[UAN_Joining_Date] [date] NULL,
[EPF_ID] [nvarchar](10) NULL,
[SalaryID] [int] NOT NULL,
[DivisionID] [int] NOT NULL,
[BranchID] [int] NOT NULL,
[AccessBy] [int] NOT NULL,
[LastUsed] [datetime] NULL,
PRIMARY KEY CLUSTERED ( [EmployeeID] ASC)
) ON [PRIMARY]
Ввод какс массовой вставкой, как показано ниже:
Ожидайте последовательное увеличение для всех записей, вставленных с массовым импортом