将文本文件传递给SQL Server [英] Passing text file to SQL Server

查看:106
本文介绍了将文本文件传递给SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我需要将文本文件中的条目传递给数据库中的相应表。我可以将整个文本文件传递给存储过程,还是可以编写VB.NET过程来解析文件并将数据传递给数据库?这是文本文件的样本

1120,011522169050,01,+ 0000001,031221,0005.95,2003,8331308,2003122

9924,014305689050, 01,+ 0000001,031221,0005.95,2003,8331308,2003122

1883,012152869050,01,+ 0000001,031222,0005.95,2003,8331308,2003122

1896, 017202869050,01,+ 0000001,031221,0005.95,2003,8331308,2003122

1896,072211119050,01,+ 0000001,031222,0005.95,2003,8331308,2003122

1908,028502869050,01,+ 0000001,031221,0005.95,2003,8331308,2003122

你能告诉我一些示例代码


谢谢

Hi
I need to pass the entries in a text file to corresponding tables in a database. Can I pass the entire text file to a stored procedure or can I write a VB.NET procedure to pharse the file and pass the data to the database? This is a sample of the text fil

1120,011522169050,01,+0000001,031221,0005.95,2003, 8331308,2003122
9924,014305689050,01,+0000001,031221,0005.95,2003, 8331308,2003122
1883,012152869050,01,+0000001,031222,0005.95,2003, 8331308,2003122
1896,017202869050,01,+0000001,031221,0005.95,2003, 8331308,2003122
1896,072211119050,01,+0000001,031222,0005.95,2003, 8331308,2003122
1908,028502869050,01,+0000001,031221,0005.95,2003, 8331308,2003122

Can you show me some sample code

Thanks

推荐答案

您应该在图书在线帮助中查看批量插入。


" Chris" <一个******* @ discussions.microsoft.com>在留言中写道

news:06 ********************************** @ microsof t.com ...
You should look at bulk insert in the Books online help.

"Chris" <an*******@discussions.microsoft.com> wrote in message
news:06**********************************@microsof t.com...

我需要将文本文件中的条目传递给
数据库中的相应表。我可以将整个文本文件传递给存储过程吗?或者我可以写一个VB.NET过程来解析文件并将数据传递给

数据库吗?这是文本文件的样本

1120,011522169050,01,+ 0000001,031221,0005.95,2003,8331308,20031222
9924,014305689050,01,+ 0000001,031221,0005.95 ,2003,8331308,20031222
1883,012152869050,01,+ 0000001,031222,0005.95,2003,8331308,20031223
1896,017202869050,01,+ 0000001,031221,0005.95,2003,8331308,20031222
1896,072211119050,01,+ 0000001,031222,0005.95,2003,8331308,20031223
1908,028502869050,01,+ 0000001,031221,0005.95,2003,8331308,20031222

谢谢
Hi,
I need to pass the entries in a text file to corresponding tables in a database. Can I pass the entire text file to a stored procedure or can I
write a VB.NET procedure to pharse the file and pass the data to the
database? This is a sample of the text file

1120,011522169050,01,+0000001,031221,0005.95,2003, 8331308,20031222
9924,014305689050,01,+0000001,031221,0005.95,2003, 8331308,20031222
1883,012152869050,01,+0000001,031222,0005.95,2003, 8331308,20031223
1896,017202869050,01,+0000001,031221,0005.95,2003, 8331308,20031222
1896,072211119050,01,+0000001,031222,0005.95,2003, 8331308,20031223
1908,028502869050,01,+0000001,031221,0005.95,2003, 8331308,20031222

Can you show me some sample code?

Thanks



如果您要直接导入文本,那么您可以只是SQL服务器导入工具。如果您正在以编程方式进行操作,那么您可以使用OleDb提供程序读取文本文件并将其插入数据库


Tu-Thac
www.ongtech.co


----- Chris写道:----


您好

我需要将文本文件中的条目传递给数据库中的相应表。我可以将整个文本文件传递给存储过程,还是可以编写VB.NET过程来解析文件并将数据传递给数据库?这是文本文件的样本

1120,011522169050,01,+ 0000001,031221,0005.95,2003,8331308,2003122

9924,014305689050,01,+ 0000001 ,031221,0005.95,2003,8331308,2003122

1883,012152869050,01,+ 0000001,031222,0005.95,2003,8331308,2003122

1896,017202869050,01, +0000001,031221,0005.95,2003,8331308,2003122

1896,072211119050,01,+ 0000001,031222,0005.95,2003,8331308,2003122

1908,028502869050, 01,+ 0000001,031221,0005.95,2003,8331308,2003122

你能告诉我一些示例代码


谢谢
If you are just going to import the text directly then you can just SQL server import utility. If you are looking at doing it programmatically, then you can use the OleDb provider to read the text file and insert it into the database

Tu-Thac
www.ongtech.co

----- Chris wrote: ----

Hi
I need to pass the entries in a text file to corresponding tables in a database. Can I pass the entire text file to a stored procedure or can I write a VB.NET procedure to pharse the file and pass the data to the database? This is a sample of the text fil
1120,011522169050,01,+0000001,031221,0005.95,2003, 8331308,2003122
9924,014305689050,01,+0000001,031221,0005.95,2003, 8331308,2003122
1883,012152869050,01,+0000001,031222,0005.95,2003, 8331308,2003122
1896,017202869050,01,+0000001,031221,0005.95,2003, 8331308,2003122
1896,072211119050,01,+0000001,031222,0005.95,2003, 8331308,2003122
1908,028502869050,01,+0000001,031221,0005.95,2003, 8331308,2003122

Can you show me some sample code

Thanks


您好

如果我需要在vb中解析这些数据并将其发送到数据库怎么办?
Hi
What if I need to pharse this data in vb and send it to the database?


这篇关于将文本文件传递给SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆