Solved

SSIS Derived column

Posted on 2011-03-10
2
1,082 Views
Last Modified: 2012-05-11
I have a stored procedure that has a companyId field formatted as follows:

Select CONVERT(VARCHAR(14),c.company_id) as CompanyId from table1

I am creating a flat file in SSIS and the companyid field needs to
be right justified, I.e. '      123456' and the maximum length of the field should be 14 spaces on the flat file.
In the SSIS Derived Column Transformation Editor i wrote the syntax:
REPLICATE(" ",14 - LEN(TRIM(CompanyId)))  in the expression field.  I thought that this would give me what i needed but it does not.


Can someone help me with the format.
I am using MS SQL Server 2008
0
Comment
Question by:MoreThanDoubled
2 Comments
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
ID: 35094247
try this

REPLICATE(" ",14 - LEN(TRIM(CompanyId)) + CompanyId
0
 

Author Comment

by:MoreThanDoubled
ID: 35094842

Thanks pratima mcs :)

I added a trim after companyId ..it works great thanks.

REPLICATE(" ",14 - LEN(TRIM(CompanyId)) + TRIM(CompanyId)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now