sql 从Excel输入Email-SkillName分配技能

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sql 从Excel输入Email-SkillName分配技能相关的知识,希望对你有一定的参考价值。

Assigning Skill From Excel Input Email-SkillName

DECLARE @tbl TABLE (
	Id INT IDENTITY(1, 1)
	,UserId INT
	,CenterPguSkillId INT
	)

INSERT INTO @tbl (
	UserId
	,CenterPguSkillId
	)
SELECT
	--s.[Level 1 Manager],
	uEng.UserId
	--,s.[Engineer Email]
	--,uEng.UserName
	--,uEng.SecondaryRole
	--,s.[Delivery Type (Work Level)]
	--,s.[Skill 1 to be Mapped]
	,vsm.CenterPguSkillId
,CASE WHEN ucxps.Id IS NULL THEN 0 ELSE 1 END AS IsAssigned
FROM dbo.Sheet2$ s
LEFT JOIN dbo.[User] uEng ON s.[Engineer Email] = uEng.Email
LEFT JOIN dbo.vw_SkillMaster vsm ON s.[Skill 3 to be Mapped] = vsm.SkillName
LEFT JOIN dbo.UserXCenter ux ON uEng.UserId = ux.UserId
LEFT JOIN dbo.UserCenterXCenterPguSkill ucxps ON ux.UserXCenterId = ucxps.UserXCenterId AND ucxps.CenterXPGUXSkillId = vsm.CenterPguSkillId AND ucxps.IsActive = 1
WHERE s.[Skill 3 to be Mapped] is not null


DECLARE @i INT = 1
DECLARE @rowCount INT = 0
DECLARE @lpUserId INT = 0
DECLARE @lpCPSId INT = 0
DECLARE @loggedInUserId nvarchar(50) = ''

SELECT @rowCount = count(1)
FROM @tbl

WHILE (@i <= @rowCount)
BEGIN
	SELECT @lpUserId = t.UserId
		,@lpCPSId = t.CenterPguSkillId
	FROM @tbl t
	WHERE id = @i

	EXEC [dbo].[USP_AssignEngineerToSKill] @centerId = 1
		,@engUserId = @lpUserId
		,@centerPguSkillId = @lpCPSId
		,@loggedInUserId = @loggedInUserId

	SET @i = @i + 1;
END

以上是关于sql 从Excel输入Email-SkillName分配技能的主要内容,如果未能解决你的问题,请参考以下文章

SSIS - 将数据从 Excel 导出到 sql 表

使用 vb.net 从 excel 文件更新 SQL 表

Excel中如何导入SQL Server里的数据

将excel表格数据转换为sql语句

VBA SQL写入语句,从一个表格写入令一个表格?

如何在 Angular 中将 csv 或 excel 文件转换为 sql 输入数组?