bcp a resultset of query in fixed width txt file

  • Hi,

    I need to do a bcp out for a query. But I am not able to get a fixed width txt file as the output.

    what are the various parameters to be set in the bcp?

  • Here is a "trick"

    casting as a char(XX) where XX is your fixed-width

    bcp "SELECT cast(LastName as char(50)) , cast(FirstName as char(50)) , cast(MiddleName as char(50)) , cast(Suffix as char(50)) FROM AdventureWorks2008.Person.Person ORDER BY LastName, Firstname" queryout PeopleAreCool.txt -c -T -SMySqlServer\MyInstanceName

    Note, that is a 2008 AdventureWorks db from code plex. Your AW db might need a slight sql-select update. But the skeleton is there.

    ..

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply