0

I've created a data flow in SSIS that takes the contents of a text file and uploads it into my SQL Server database table as a BlobColumn. The text file is a document containing sentences, carriage returns and line feeds. I have an Execute SQL transform that loads the file as follows:

 Use MyDB;
 Create Table TextToToken(Filename nvarchar(60), FileType nvarchar(60), Document varbinary(max));
 Go

 Insert into TextToToken(Filename, FileType, Document)
 Select 'TokenDoc1.txt' as Filename, '*.txt' as FileType,  
 * from OPENROWSET(BULK N'C:\Docs\Doc1.txt', SINGLE_BLOB) as Document
 Go

I've created a script component that reads the Document BlobColumn and I tried just parsing words that are separated by commas using the following:

 public override void Input0_ProcessInputRow(Input0Buffer Row)
{
    string[] words = BlobToString(Row);
}
private string BlobToString(BlobColumn blob)
{
    string result = "";
    try
    {
        if (blob != null)
        {
            result = System.Text.Encoding.Unicode.GetString(blob.GetBlobData(0, Convert.ToInt32(blob.Length)));
        }
    }
    catch (Exception ex)
    {
        result = ex.Message;
    }
    return result;
}

How do I augment the above to separate words based on period, space and carriage return line feed in addition to comma?

4

0 回答 0