Terry Ambrosius
asked on
SQLCMD question to have fields created as fixed length
I need to use SQLCMD to bring some data back from a SQL table and need to create a txt file. In the txt file I need to have the
fields be at a specific length/location.
Select field1, field2 from table (see Below)
The txt file needs to have the fields start in specific columns,
Tried to use the cast function and that runs the fields together
SELECT PLEV, CAST(JCODE AS char(15)) as JCODE, PGRP
from dbo.TIMERS where JCODE in ('TECHNICAN','SALES') -W -w 999 -s"" >> "C:\OutputFTPFiles\testfil e" -h-1
What I need to see as output is
PLEV JCODE PGRP
1234 TECHNICIAN AAAA
5678 SALES AAAA
What I see when I run the process
1234TECHNICIAN AAAA
5678SALESAAAA
Any Ideas would be appreciated.
fields be at a specific length/location.
Select field1, field2 from table (see Below)
The txt file needs to have the fields start in specific columns,
Tried to use the cast function and that runs the fields together
SELECT PLEV, CAST(JCODE AS char(15)) as JCODE, PGRP
from dbo.TIMERS where JCODE in ('TECHNICAN','SALES') -W -w 999 -s"" >> "C:\OutputFTPFiles\testfil
What I need to see as output is
PLEV JCODE PGRP
1234 TECHNICIAN AAAA
5678 SALES AAAA
What I see when I run the process
1234TECHNICIAN AAAA
5678SALESAAAA
Any Ideas would be appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER