I am looking for a stored procedure code that will open a text file, read in several thousand lines, and add the code to a table in the database. Is there a simple way to implement this in T-SQL?
If the file is ready to load "as-is" (no data transformations or complex mappings required), you can use the Bulk Insert command:
CREATE PROC dbo.uspImportTextFile
AS
BULK INSERT Tablename FROM 'C:\ImportFile.txt'
WITH ( FIELDTERMINATOR ='|', FIRSTROW = 2 )