SQL Server批量插入 [英] SQL Server mass insert

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

问题描述



我正在尝试编写一个脚本,以将国家/地区列表及其相应的帐号插入SQL的表中.
但是,系统管理员不允许我直接将文件链接或导入到表中,因此我必须设置一个过程来手动导入这些数据.

我正在尝试做

Hi,

I am trying to do a script to insert a list of country and their corresponding account numbers to a table in SQL.
However the system admin does not allow me to link or import the file into a table directly hence I have to set up a procedure to manually import those data.

I am trying to do a

INSERT INTO Finance_APAC.dbo.testBreakAsean (Country, Account) VALUES ('Test1','Test2')
INSERT INTO Finance_APAC.dbo.testBreakAsean (Country, Account) VALUES ('Test3','Test4')
INSERT INTO Finance_APAC.dbo.testBreakAsean (Country, Account) VALUES ('Test5','Test6')



并使用公式从excel工作表中捕获那些国家/帐户编号,然后将insert命令粘贴到我的SQL Server中,但是当我使用'',"时excel会报告错误,这对于我来说是必须的插入国家或帐户

无论如何有回避这个问题?这可能比SQL更像是一个Excel问题.感谢您对此的任何专业知识.



and use a formula to trap those country/account numbers from an excel sheet and do a paste of the insert command into my SQL server, however excel would report errors when I use a "'',''" which is neccessary for me to insert the Country or account

Is there anyway to sidestep this problem? This might be more of an excel question then SQL. Thanks for any expertise on this.

推荐答案

SQL SERVER – 2008 –使用一个插入语句插入多个记录–使用行构造器 [将数据导入到SQL使用批量插入功能的Excel服务器 [
SQL SERVER – Insert Multiple Records Using One Insert Statement – Use of UNION ALL[^]

SQL SERVER – 2008 – Insert Multiple Records Using One Insert Statement – Use of Row Constructor[^]


Importing Data to SQL Server from Excel using Bulk Insert[^]
[/Edit]


那位犹太人,

谢谢您的帮助. :)
Hi thatraja,

Thanks for the help. :)


这篇关于SQL Server批量插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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