我希望如何通过这两个表获取员工薪资信息和EMPLOYEE_CODE,FIRST_NAME,我希望员工ramesh薪水等员工的工资是1000 rs ..以及员工代码中TBL_BASIC_SALARY的变化。
TBL_ADDNEW_EMPLOYEE HERE EMPLOYEE INFORMATION
EMPLOYEE_ID IS PRIMARY KEY
EMPLOYEE_ID int
EMPLOYEE_CODE varchar(200)=NULL
FIRST_NAME varchar(200)=NULL
LAST_NAME varchar(200)=NULL
USER_NAME varchar(400)=NULL
FATHER_NAME varchar(200)=NULL
MOTHER_NAME varchar(200)=NULL
GENDER varchar(50)=NULL
DEPARTMENT varchar(200)=NULL
DESIGNATION varchar(200)=NULL
PROFILE_PIC varchar(200)=NULL
ADDRESS varchar(200)=NULL
SECOND TABLE TBL_BASIC_SALARY
WHERE SALARY_ID IS PRIMARY KEYS
SALARY_ID int
BASIC_SALARY decimal(18, 0)=NULL
SALARY_TYPE varchar(50)=NULL
AND ADD INFORMATION DETAILS OF EMPLOYEE AND EMPLOYEE_CODE ARE UNIQUE FOR EVERY EMPLOYEE
ALTER PROCEDURE [dbo].[USP_ADDNEW_EMPLOYEE]
-- Add the parameters for the stored procedure here
@EMPLOYEE_CODE VARCHAR(200)=NULL,
@FIRST_NAME VARCHAR(200)=NULL,
@LAST_NAME VARCHAR(200)=NULL,
@USER_NAME VARCHAR(400)=NULL,
@FATHER_NAME VARCHAR(200)=NULL,
@MOTHER_NAME VARCHAR(200)=NULL,
@GENDER VARCHAR(200)=NULL,
@DEPARTMENT VARCHAR(200)=NULL,
@DESIGNATION VARCHAR(200)=NULL,
@PROFILE_PIC VARCHAR(200)=NULL,
@FILENAME VARCHAR(500)=NULL,
@FILE_EXTENSION VARCHAR(10)=NULL,
enter code here
@ADDRESS VARCHAR(200)=NULL,
BEGIN
--*********FOR ADD PRODUCTS INFORMATION***************************************************------
Declare @CurrentID varchar(500)
Declare @NewFileName VARCHAR(500)
IF(@Calltype='ADD_EMPLOYEE_INFO')
BEGIN
IF EXISTS(SELECT EMPLOYEE_ID FROM TBL_ADDNEW_EMPLOYEE where EMPLOYEE_CODE=@EMPLOYEE_CODE)
BEGIN
SELECT 1 AS SUCCESS
END
ELSE
BEGIN
INSERT INTO TBL_ADDNEW_EMPLOYEE
(
EMPLOYEE_CODE,FIRST_NAME,LAST_NAME,FATHER_NAME,MOTHER_NAME,GENDER,DEPARTMENT,
DESIGNATION,PROFILE_PIC,ADDRESS,
)
VALUES
(
@EMPLOYEE_CODE,@FIRST_NAME,@LAST_NAME,@FATHER_NAME,@MOTHER_NAME,@GENDER,@DEPARTMENT,
@DESIGNATION,@PROFILE_PIC,@ADDRESS,
)
SET @CurrentID=(SELECT @@IDENTITY)
SET @NewFileName=@FILENAME+'_'+@CurrentID +'.'+@FILE_EXTENSION
UPDATE TBL_ADDNEW_EMPLOYEE SET PROFILE_PIC=@NewFileName
WHERE EMPLOYEE_ID=@CurrentID
SELECT @NewFileName AS SCUCESS
END
END
我希望如何通过这两个表获取员工薪资信息和EMPLOYEE_CODE,FIRST_NAME,我希望员工ramesh薪水等员工的工资是1000 rs ..以及员工代码中TBL_BASIC_SALARY的变化。
答案 0 :(得分:0)
目前TBL_ADDNEW_EMPLOYEE
和TBL_BASIC_SALARY
之间没有映射,因此您可以根据自己的要求实施映射...
在TBL_BASIC_SALARY
表格中,添加EMPLOYEE_ID
列并使用TBL_ADDNEW_EMPLOYEE
创建外键约束。
第二个您可以创建一个新的关联表并添加EMPLOYEE_ID
和SALARY_ID
列,并为这两个表创建外键约束。在插入数据时,您必须将两个表的@@IDENTITY
插入到这个新的关联表中。
现在使用SQL连接来检索结果。