--create table tmptest (test text null)
BULK INSERT dbo.tmptest
FROM '<input file>'
WITH
(
ROWTERMINATOR = '\0'
)
-- Step through each record and pull in the data from the email
declare @cFname char(200)
declare @RowNum int
declare @InsNote Varchar(3000)
declare @Tid Char(10)
declare fNameList cursor for select * From #files
OPEN fNameList
FETCH NEXT FROM fNameList
INTO @cFname
set @RowNum = 0
WHILE @@FETCH_STATUS = 0
BEGIN
set @RowNum = @RowNum + 1
--print cast(@RowNum as char(1)) + "' " + @cFname + "'"
print @cFname
Delete From ##MyTable
-- Put the magic here
exec(@cFname)
Select Top 1 @Tid = SubString(cBody,CharIndex(' ',cBody),Len(cBody)-CharIndex(' ',cBody)+1) from ##MyTable
Select @InsNote = cBody From ##MyTable
Select @InsNote
insert into table_notes (Note ,TicketId,DateCreated,WrittenBy,PrintableYN,CustViewYN,BillingYN)
Values(@InsNote,@Tid ,GetDate() ,22 ,'Yes' ,'No' ,0)
-- End Put the magic here
FETCH NEXT FROM fNameList
INTO @cFname
END
CLOSE fNameList
DEALLOCATE fNamelist