打开和读取文本文件的存储过程 [英] Stored Procedure to Open and Read a text file
本文介绍了打开和读取文本文件的存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找一个存储过程代码,它可以打开一个文本文件,读取几千行,然后将代码添加到数据库中的表中.有没有一种简单的方法可以在 T-SQL 中实现这一点?
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 )
http://msdn.microsoft.com/en-us/library/ms188365.aspx
这篇关于打开和读取文本文件的存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文