使用T-SQL,是否可以在不锁定的情况下将记录插入表中? [英] Using T-SQL, is it possible to insert records into a table without locking it?
本文介绍了使用T-SQL,是否可以在不锁定的情况下将记录插入表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个向表中插入数百万条记录的进程.
I have a process that inserts millions of records into a table.
当它正在执行时,没有其他进程可以访问该表.他们必须等待几分钟.不接受网络应用.
While it's being executed, no other process can access that table. They have to wait a few minutes. Unacceptable for web apps.
那么,有没有像 BULK INSERT 这样的东西可以在两个 sql 表之间使用?
So, is there something like BULK INSERT that can be used between two sql tables ?
谢谢!
推荐答案
那么,有没有像 BULK INSERT 这样的东西可以在两个sql表?
So, is there something like BULK INSERT that can be used between two sql tables ?
是的...它被称为 BULK INSERT 但它是从表到表的两步过程:
Yes there is... it's called BULK INSERT but it's a two step process to go from table to table:
在本地保存数据:
execute xp_cmdshell 'bcp Northwind.dbo.Orders out c:\temp\Orders.txt -Sgalser01 -T -n'
然后批量插入保存的文件:
Then bulk insert the saved file:
select * into Northwind.dbo.Orders2 from Northwind.dbo.Orders where 1=2
bulk insert Northwind.dbo.Orders2 from 'c:\temp\Orders.txt'
with (DATAFILETYPE = 'native')
这篇关于使用T-SQL,是否可以在不锁定的情况下将记录插入表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文