将超过 1000 行从 Excel 插入 SQLServer

2022-01-09 00:00:00 sql insert sql-server-2008 sql-server

我是 Sql 新手,但是将 1000 多行从 excel 文档插入我的数据库的最佳方法是什么(Sql server 2008.)

I'm new to Sql but what is the best way to insert more than 1000 rows from an excel document into my database(Sql server 2008.)

例如,我正在使用以下查询:

For example I'm using the below query:

   INSERT INTO mytable(companyid, category, sub, catalogueref)
   VALUES
   ('10197', 'cat', 'sub', '123'),
   ('10197', 'cat2', 'sub2', '124')

这工作正常,但有插入 1000 条记录的限制,我有 19000 条记录,我真的不想做 19 条单独的插入语句,另一个问题是,公司 ID 总是相同的写 19000 次更好吗?

This is working fine but there is a limit of inserting 1000 records and I have 19000 records and I don't really want to do 19 separate insert statements and another question, is that the company id is always the same is there a better way then writing it 19000 times?

推荐答案

微软提供了一个导入向导 与 SQL Server.我用它从其他数据库和电子表格中迁移数据.它非常强大且易于使用.

Microsoft provides an import wizard with SQL Server. I've used it to migrate data from other databases and from spreadsheets. It is pretty robust and easy to use.

相关文章