Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
LEFT justify and Replicate Spaces as required
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Import/Export
Divers
Thread ID:
00998925
Message ID:
00998937
Vues:
16
Sergey;

That worked like a charm! Thank you very much. This will resolve this issue which effects about a dozen fields. I have another question that I will post in a new message. If this keeps up I will hvae a great weekend! We have tomorrow off.

Tom

>Tom,
>
>Try
SELECT [NAME Code]
>     + CONVERT( char(30),  ISNULL(CONVERT(VARCHAR(30), [Scrap Reference Number]), ' '))
A couple of comments:
>- It's better always specify data size so you don't get bitten by defaults
>- I would use CAST() instead of CONVERT() because it's ANSI standard
>
CAST ( ISNULL( CAST([Scrap Reference Number] AS VARCHAR(30)), ' ') AS char(30))
>
>>I have to create several files to FTP to a UNIX machine. The layout of the data is column specific that is each column has a maximum length and position.
>>
>>I have a requirement to LEFT justify a number of fields in a Select Statement. I then have to Pad with Spaces to the required number of characters, in this case the maximum length is 30. The code below works as desired but RIGHT justifies the result.
>>
>>The code below represents a fragment of the Select statement to simplify the question.
>>
>>
>>SELECT [NAME Code]
>>     +SUBSTRING(REPLICATE(' ', 30-LEN(CONVERT(VARCHAR, [Scrap Reference Number])))
>  ISNULL(CONVERT(VARCHAR, [Scrap Reference Number]), ' '),1,30)
>>
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform