Why is this expression not working in SSIS Dervied COlumn Trans;
right('000'+convert(nvarchar,columnname),12)
Why is this expression not working in SSIS Dervied COlumn Trans;
right('000'+convert(nvarchar,columnname),12)
The NVARCHAR needs a length after it. NVARCHAR(30) would accommodate a 30 character length string, use something at least the size of the column you are converting. Use RIGHT('000'+CONVERT(NVARCHAR(30),columnname),12)
e.g.
use adventureworks
go
select right('000'+convert(nvarchar(30),humanresources.employee.NationalIDNumber),10)
from humanresources.employee
i tired but it shows this error
Error at Data Flow Task 1 [Derived Column [2987]]: The function "NVARCHAR" was not recognized. Either the function name is incorrect or does not exist.
Error at Data Flow Task 1 [Derived Column [2987]]: Attempt to parse the expression "RIGHT("000"+CONVERT(NVARCHAR(255), [columnname] ),12)" failed and returned error code 0xC004708A. The expression cannot be parsed. It might contain invalid elements or it might not be well-formed. There may also be an out-of-memory error.
Error at Data Flow Task 1 [Derived Column [2987]]: Cannot parse the expression "RIGHT("000"+CONVERT(NVARCHAR(255), [columnname] ),12)". The expression was not valid, or there is an out-of-memory error.
Error at Data Flow Task 1 [Derived Column [2987]]: The expression "RIGHT("000"+CONVERT(NVARCHAR(255), [columnname] ),12)" on "output column "Derived Column 1" (3038)" is not valid.
Error at Data Flow Task 1 [Derived Column [2987]]: Failed to set property "Expression" on "output column "Derived Column 1" (3038)".
ADDITIONAL INFORMATION:
Exception from HRESULT: 0xC0204006 (Microsoft.SqlServer.DTSPipelineWrap)
BUTTONS:
No one has followed this question yet.