I am creating a “Ragged right” (fixed) format file using a SQL to specify the data to extract.
SELECT
'D' AS DTL_REC_TYP
,CAST(CONVERT(VARCHAR, dbo.GetCycleDate(), 120) AS CHAR(10)) AS DTL_FILE_GL_DT
,CAST(CONVERT(VARCHAR, GETDATE(), 120) AS CHAR(19)) AS DTL_FILE_CREATE_DT
,LEGAL_ENTTY_CD AS DTL_LEGAL_ENTITY
,CLIENT_ID AS DTL_CLIENT_ID
,ACCT_NUM AS DTL_ACCT_NUM
,BEN_OPT_CD AS DTL_BEN_OPT_CD
FROM
MyTable
Client_ID is an INT column in the database.
Q: How do I get the value to be right justified within the column?
I was considering changing my SQL to do this, but this seems ugly:
,RIGHT('000000000' + CAST(CLIENT_ID As varchar(9)),9) AS DTL_CLIENT_ID
or
,RIGHT(' ' + CAST(CLIENT_ID As varchar(9)),9) AS DTL_CLIENT_ID
Is there a better way to do it in SSIS instead of T-SQL. If not, is there a slightly better way in T-SQL? It seems to me that the format of the fixed flat file should or at least could be be soley defined in SSIS and that the SQL.

Doing the formatting in SQL is ugly, but it does work.
I prefer doing the formatting in a Script Component of a Data Flow Task, mainly because String.Format is so much more powerful than anything in T-SQL. In this case, the script would go between the DB data source of your choice and the flat file destination.
You’d change the query to something like this:
where you’re no longer trying to convert the numerics in the SQL. All the columns from your query would become input columns to the script component. For every column you want to format, add an output column to the script component with the data type of DT_WSTR and the appropriate width. In the script component itself, you just have to add code to the ProcessInputRow event:
Then your flat file destination just consumes the string output columns.