--===== Create a temp table to import the file to CREATE TABLE #AllData (RawData VARCHAR(8000))--===== Import the data into a single column using all defaults. BULK INSERT #AllData FROM 'C:\Temp\SomeFile.txt' --This is where I saved the example file--===== Declare some obviously named local variablesDECLARE @PeriodEnding DATETIME--===== Populate a variable with the Period Ending date from the file header SELECT TOP 1 --Just to short circuit the table scan... @PeriodEnding = SUBSTRING(RawData,PATINDEX('%[0-1][0-9]/[0-3][0-9]/[2][0-9][0-9][0-9]%',RawData),10) FROM #AllData WHERE RawData LIKE '%FOR PERIOD ENDING [0-1][0-9]/[0-3][0-9]/[2][0-9][0-9][0-9]%'--===== Return a result set with the CodeValue numbers and the Period Ending date... SELECT LTRIM(RTRIM(RawData)) AS CodeValue, @PeriodEnding AS EndDate FROM #AllData WHERE SUBSTRING(RawData,2,1) > '' AND RawData NOT LIKE ' POLICY NO%'