Technical Article

Read a text file from SQL Server query analyzer

,

Here's a script that will read a text file from the Windows system into SQL Server

CREATE PROC Sp_EnterTextFile @filename sysname 
as 
BEGIN 
   SET nocount ON 
   CREATE TABLE #tempf (line varchar(8000)) 
   EXEC ('bulk INSERT #tempf FROM "' + @filename + '"') 
   SELECT * FROM #tempf 
   DROP TABLE #tempf 
END 
GO

Rate

You rated this post out of 5. Change rating

Share

Share

Rate

You rated this post out of 5. Change rating