Set the CSV columns width

  • When we are loading the data from sql to CSV. Can we set the colum width of the destination. Say if we have text in column of length 10, then can we set the width to the same in CSV, so that when we see the CSV, we should able to see the entire text. Hope you all got me.

    Please Advice.

  • Are you having difficulty with this, or just checking to see if it is possible?

    The nature of CSV files is that each column is output for each row at exactly the size required to fit all of the column data. This makes each row in the CSV file a different length based on the actual data in each row.

    By default, you should always be able to see the entire contents of the column.

  • There really isn't enough information to do anything with here - what method are you using to load the data? SSIS? DTS Package? 3rd party tool?

  • jerry-621596 (10/1/2010)


    Are you having difficulty with this, or just checking to see if it is possible?

    The nature of CSV files is that each column is output for each row at exactly the size required to fit all of the column data. This makes each row in the CSV file a different length based on the actual data in each row.

    By default, you should always be able to see the entire contents of the column.

    It looks like below when I load the data.

    But I want to see the data in this manner

  • getoffmyfoot (10/1/2010)


    There really isn't enough information to do anything with here - what method are you using to load the data? SSIS? DTS Package? 3rd party tool?

    Well, I am using SSIS 2008 To Load the data.

  • I'm assuming that you're then using Excel to open the CSV, and want all of the column's auto-sized?

    Setting the width in a CSV file defeats the nature of a CSV - each piece of data is delimited with a comma.

    Perhaps what you're thinking about is fixed format file? Or convert all of the columns to a fixed character length (I'd use the select statement to convert them, but you could do it also with a derived column task)

    Wayne
    Microsoft Certified Master: SQL Server 2008
    Author - SQL Server T-SQL Recipes


    If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
    Links:
    For better assistance in answering your questions
    Performance Problems
    Common date/time routines
    Understanding and Using APPLY Part 1 & Part 2

Viewing 6 posts - 1 through 5 (of 5 total)

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