SELECT tbl_karyawan.id_karyawan, tbl_karyawan.email
FROM tbl_mentor_data
JOIN tbl_karyawan ON tbl_mentor_data.nomor = tbl_karyawan.id_karyawan
WHERE tbl_mentor_data.nomor IS NOT NULL;
给我:
将 varchar 值 '0001/KMG/03/2024' 转换为数据类型 int 时转换失败
请帮我解决这个问题
我尝试加入2张桌子, 第一个表是 tbl_karyawan 将获取数据 nama、id_karyawan 和 email 第二个表是 tbl_mentor_data 将从该表获取所有数据
这段代码:
{ 创建函数 [dbo].[SplitString]
(
@InputString NVARCHAR(MAX),
@分隔符NVARCHAR(255)
)
返回 @OutputTable 表(项目 NVARCHAR(MAX))
AS
开始
声明@StartIndex INT,@EndIndex INT
SET @StartIndex = 1
SET @EndIndex = CHARINDEX(@Delimiter, @InputString)
WHILE @EndIndex > 0
BEGIN
INSERT INTO @OutputTable (Item)
VALUES (SUBSTRING(@InputString, @StartIndex, @EndIndex - @StartIndex))
SET @StartIndex = @EndIndex + LEN(@Delimiter)
SET @EndIndex = CHARINDEX(@Delimiter, @InputString, @StartIndex)
END
INSERT INTO @OutputTable (Item)
VALUES (SUBSTRING(@InputString, @StartIndex, LEN(@InputString) - @StartIndex + 1))
RETURN
END
with temp as ( select * from dbo.[SplitString]('0001/KMG/03/2024','/'))
select item=cast(item as bigint) from temp where isnumeric(item)!=0
}