SQL 错误:字符串或二进制数据将被截断
我有一个表变量 @RQ
,我希望使用表值函数更新它。 现在,我认为我更新错误了,因为我的函数有效...
函数:
ALTER FUNCTION [dbo].[usf_GetRecursiveFoobar]
(
@para int,
@para datetime,
@para varchar(30)
)
RETURNS @ReQ TABLE
(
Onekey int,
Studnr nvarchar(10),
Stud int,
Description nvarchar(32),
ECTSGot decimal(5,2),
SBUGot decimal(5,0),
ECTSmax decimal(5,2),
SBUmax decimal(5,0),
IsFree bit,
IsGot int,
DateGot nvarchar(10),
lvl int,
path varchar(max)
)
AS
BEGIN;
WITH RQ
AS
(
--RECURSIVE QUERY
)
INSERT @ReQ
SELECT
RQ.Onekey,
RQ.Studnr,
RQ.Stud,
RQ.Description,
RQ.ECTSGot,
RQ.SBUGot,
RQ.ECTSmax,
RQ.SBUmax,
RQ.IsFree,
RQ.IsGot,
RQ.DatumGot,
RQ.lvl,
RQ.path
FROM
RQ
RETURN
END
现在,当我运行一个简单的查询时:
DECLARE @ReQ TABLE
(
OnderwijsEenheid_key int,
StudentnummerHSA nvarchar(10),
Student_key int,
Omschrijving nvarchar(32),
ECTSbehaald decimal(5,2),
SBUbehaald decimal(5,0),
ECTSmax decimal(5,2),
SBUmax decimal(5,0),
IsVrijstelling bit,
IsBehaald int,
DatumBehaald nvarchar(10),
lvl int,
path varchar(max)
)
INSERT INTO @ReQ
SELECT *
FROM usf_GetRecursiveFoobar(@para1, @para2, @para3)
我收到错误:
消息 8152,第 16 级,状态 13,第 20 行 字符串或二进制数据将被截断。 该声明已终止。
为什么?该怎么办呢?
I got a table variable @RQ
, I want it updated using a table-valued function.
Now, I think I do the update wrong, because my function works...
The function:
ALTER FUNCTION [dbo].[usf_GetRecursiveFoobar]
(
@para int,
@para datetime,
@para varchar(30)
)
RETURNS @ReQ TABLE
(
Onekey int,
Studnr nvarchar(10),
Stud int,
Description nvarchar(32),
ECTSGot decimal(5,2),
SBUGot decimal(5,0),
ECTSmax decimal(5,2),
SBUmax decimal(5,0),
IsFree bit,
IsGot int,
DateGot nvarchar(10),
lvl int,
path varchar(max)
)
AS
BEGIN;
WITH RQ
AS
(
--RECURSIVE QUERY
)
INSERT @ReQ
SELECT
RQ.Onekey,
RQ.Studnr,
RQ.Stud,
RQ.Description,
RQ.ECTSGot,
RQ.SBUGot,
RQ.ECTSmax,
RQ.SBUmax,
RQ.IsFree,
RQ.IsGot,
RQ.DatumGot,
RQ.lvl,
RQ.path
FROM
RQ
RETURN
END
Now, when I run a simple query:
DECLARE @ReQ TABLE
(
OnderwijsEenheid_key int,
StudentnummerHSA nvarchar(10),
Student_key int,
Omschrijving nvarchar(32),
ECTSbehaald decimal(5,2),
SBUbehaald decimal(5,0),
ECTSmax decimal(5,2),
SBUmax decimal(5,0),
IsVrijstelling bit,
IsBehaald int,
DatumBehaald nvarchar(10),
lvl int,
path varchar(max)
)
INSERT INTO @ReQ
SELECT *
FROM usf_GetRecursiveFoobar(@para1, @para2, @para3)
I got error:
Msg 8152, Level 16, State 13, Line 20
String or binary data would be truncated.
The statement has been terminated.
Why? What to do about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的。我的错...
试图用 varchar(10) 填充 10 个字符的长字符串。所以失败了...
Ok. my fault...
a varchar(10) was tried to be filled with a 10-character long string. So it failed...