June 4, 2009 at 1:55 pm
I am developing a view that will eventually be used as the source for a nightly extraction to a flat file. This flat file requires that each field uses certain columns, for example Field 1 uses columns 1 - 20, Field 2 uses 21-24, etc.
I like to set up my view/query to make each field its appropriate length, need the right code to set the field length.
Field 1 from the source table is 24, but in my view it needs to be 20.
June 5, 2009 at 3:03 am
robert_daniel (6/4/2009)
I am developing a view that will eventually be used as the source for a nightly extraction to a flat file. This flat file requires that each field uses certain columns, for example Field 1 uses columns 1 - 20, Field 2 uses 21-24, etc.I like to set up my view/query to make each field its appropriate length, need the right code to set the field length.
Field 1 from the source table is 24, but in my view it needs to be 20.
Sounds like you can just cast these to the appropriate lengths, although from your example you will
be truncating data.
SELECT CAST(Field1 AS CHAR(20)) AS Field1
...
FROM ...
____________________________________________________
Deja View - The strange feeling that somewhere, sometime you've optimised this query before
How to get the best help on a forum
http://www.sqlservercentral.com/articles/Best+Practices/61537June 5, 2009 at 3:45 am
Hi,
some more specification will help to better understand the problem.
"Don't limit your challenges, challenge your limits"
June 5, 2009 at 9:05 am
Looks like CAST will do the trick - thanks!
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply