Solved

SSIS Derived column

Posted on 2011-03-10
2
1,088 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how the fundamental information of how to create a table.

786 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