Question : Exporting Data Blob

Hello, I have Goldmine SQL version and I need to export the notes from Goldmine into Navision.  The problem is the Goldmine stores the notes as a data blob and Navision stores the notes as line items that are only 80 characters long.  In Navision, if the note is longer, you have to add another line.  So I can't do a DTS transfer between the databases because Navision only pulls the first 80 characters and leaves out the rest.  When I export Goldmine to a text file, it doesn't come out in consistant rows and columns, meaning, the notes can be in a range of columns or rows, but there is not enough consistancy to import them.  Anyone have ideas on converting the notes from a data blob into multiple 80 character lines?

Answer : Exporting Data Blob

Something like this perhaps:

DECLARE @cus_no varchar(20),
      @ColLength integer,
      @CurrPos integer,
      @MaxLength smallint,
      @Size smallint,
      @LineNumber integer

DECLARE @Temp TABLE (
      cus_no varchar(20),
      LineNumber integer,
      Notes varchar(80))

SET NOCOUNT ON
SET @MaxLength = 80

DECLARE Notes_cursor CURSOR FOR
SELECT      cus_no, DATALENGTH(Notes) AS ColLength
FROM      Customer_Template

OPEN Notes_Cursor

FETCH Next FROM Notes_Cursor INTO @cus_no, @ColLength

WHILE @@FETCH_STATUS = 0
   BEGIN
      SELECT      @CurrPos = 1,
                  @LineNumber = 10000
      WHILE @CurrPos <= @ColLength
         BEGIN
            IF (@ColLength - @CurrPos + 1) <= @MaxLength
               BEGIN
                  SET @Size = @ColLength - @CurrPos + 1
               END
            ELSE
               BEGIN
                  SET @Size = @MaxLength
               END
            
            INSERT      @Temp (cus_no, LineNumber, Notes)
        SELECT      @cus_no,
                    @LineNumber,
                    SUBSTRING(notes, @CurrPos, @Size)
        FROM      Customer_Template
        WHERE      cus_no = @cus_no

            SELECT @CurrPos = @CurrPos + @MaxLength,
                   @LineNumber  = @LineNumber + 10000
         END
      FETCH NEXT FROM Notes_Cursor INTO @cus_no, @ColLength
   END
CLOSE Notes_Cursor
DEALLOCATE Notes_Cursor

SELECT     *
FROM         @Temp
Random Solutions  
 
programming4us programming4us