Creating a stored procedure is straight-forward. Have a look in the on-line help for SQL Server (T-SQL). As for what you want to do I think the simplest thing to do is to load your data (as you already have) and then move it around. Something like this...
CREATE PROCEDURE [LoadFile]
@SourceFilePath varchar(512),
@LogFilePath varchar(512)
AS
BEGIN
SET NOCOUNT ON;
SELECT CAST(NULL AS VARCHAR(255)) AS [LineText] INTO #IMPORTBUFFER WHERE 1 = 0
exec('
BULK INSERT #ImportBuffer
FROM ''' + @SourceFilePath + '''
WITH (
ROWTERMINATOR = ''\n'',
ERRORFILE = ''' + @LogFilePath + '''
);
')
INSERT INTO MyIndexTable([ID], [NAME], [MESSAGE])
SELECT
SUBSTRING([LineText], 1,1),
SUBSTRING([LineText], 2,8),
SUBSTRING([LineText], 11,9)
FROM [#ImportBuffer]
WHERE {any where clauses that might be necessary}
Insert into [FinalTable] ([ImportedText])
SELECT
[LineText]
FROM [#ImportBuffer]
WHERE {any where clauses that might be necessary}
END
GO
And to test it...
declare @filePath varchar(512)
declare @errorLogPath varchar(512)
set @filePath = 'C:\@scratch\somedata.txt'
set @errorLogPath = 'C:\scratch\error.log'
truncate table MyIndexTable
select * from MyIndexTable
exec LoadFile @filePath, @errorLogPath
select * from MyOtherTable