SSIS: Flat File default length

后端 未结 3 1969
借酒劲吻你
借酒劲吻你 2021-01-06 08:35

I have to import about 50 different types of files every day. Some of them with a few columns, some inculde up to 250 columns.

The Flat File connection always defaul

3条回答
  •  醉话见心
    2021-01-06 09:17

    I don't think that there is a way to achieve this from SQL Server Data Tools.

    But you can do some workaround to achieve this:

    1. Easiest solution, In the Flat file connection manager - Advanced Tab, select all columns (using Ctrl key) and change the data length property for them all in one edit. (detailed in @MikeHoney answer)
    2. You can use BIML (Business Intelligence Markup Language) to create ssis package, if you're new to BIML you can access to BIML Script website for detailed tutorials.

    3. You can create a Small application that loop over .dtsx files in a folder and replace DTS:MaximumWidth="50" with DTS:MaximumWidth="500" using normal String.Replace function or using Regular expressions. (you can read my answer @ Automate Version number Retrieval from .Dtsx files to see an exmaple on reading .dtsx file using Regular expressions)

    Function To Read and Replace content of dtsx file (Vb.Net)

    Public Sub FixDTSX(byval strFile as string)
    
        dim strContent as string = string.empty
    
        Using sr as new Io.StreamReader(strFile)
    
            strContent = sr.ReadToEnd()
    
            sr.Close()
    
        End Using
    
        strContent = strContent.Replace("DTS:MaximumWidth=""50""","DTS:MaximumWidth=""500""")
    
        Using sw as new Io.StreamWriter(strFile,False)
    
            sw.Write(strContent)
    
            sw.Close()
    
        End Using
    
    End Sub
    

提交回复
热议问题