2010-06-08 94 views
2

我得到一個表變量@RQ,我希望它使用表值函數更新。 現在,我覺得我做的更新錯誤的,因爲我的函數的工作...SQL錯誤:字符串或二進制數據將被截斷

功能:

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) 

我錯誤:

Msg 8152, Level 16, State 13, Line 20 String or binary data would be truncated. The statement has been terminated.

爲什麼?該怎麼辦?

回答

3

好的。我的錯...

varchar(10)被試圖填充一個10個字符的長字符串。所以它失敗了......

相關問題