x

SSIS Dervied Column

Why is this expression not working in SSIS Dervied COlumn Trans;

right('000'+convert(nvarchar,columnname),12)

more ▼

asked Feb 12, 2010 at 03:13 PM in Default

InwoodGuy gravatar image

InwoodGuy
44 7 8 8

(comments are locked)
10|1200 characters needed characters left

3 answers: sort voted first

NVARCHAR isn't recognized in SSIS, in the derived column expression, try this:

RIGHT("000" + (DT_WSTR,30)column_name,10)

NVARCHAR is Unicode in SQL Server, DT_WSTR in SSIS

more ▼

answered Feb 12, 2010 at 05:22 PM

Jay Bonk gravatar image

Jay Bonk
1.4k 2

(comments are locked)
10|1200 characters needed characters left

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 
more ▼

answered Feb 12, 2010 at 03:35 PM

Fatherjack gravatar image

Fatherjack ♦♦
42.7k 75 79 108

(comments are locked)
10|1200 characters needed characters left

i tired but it shows this error

TITLE: Microsoft Visual Studio

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:

OK

more ▼

answered Feb 12, 2010 at 03:46 PM

InwoodGuy gravatar image

InwoodGuy
44 7 8 8

what is the datatype of the column you are converting?
Feb 12, 2010 at 03:53 PM Fatherjack ♦♦
source is nvarchar(30) I need to add leading zeros using Derived Transformation is SSIS.
Feb 12, 2010 at 04:08 PM InwoodGuy
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1950
x939

asked: Feb 12, 2010 at 03:13 PM

Seen: 2931 times

Last Updated: Feb 12, 2010 at 03:13 PM