如何根据 SQL Server 表验证 PowerShell 中的大数据集
我有几百行数据,每行大约 100 字节,需要针对 SQL Server 中相当大(数百万行)的表验证字段值。 SQL 上的查询本身非常快,但从脚本中每行运行单个查询并不慢,可能是因为连接设置和拆卸的原因。我无法将任何存储过程添加到服务器。有什么方法可以将数据集/表从脚本传递给查询并返回结果,而不是逐行迭代数据集?当然,PowerShell 代码示例将受到欢迎;)
I have couple hundred rows of data of about 100 bytes each and need the field values validated against fairly large (milions of rows) table in SQL server. The query itself on SQL is very quick, but running single query per row from the script is not slow, probably because of the connection set-up and teardown. I can't add any stored procs to the server. Is there any way how to pass a dataset/table to a query from the script and return results rather then iterate the dataset row-by-row? Of course PowerShell code samples would be welcome ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有办法通过 powershell(或我知道的任何其他方法),因为 SQL Server 无法接受表作为查询中的输入参数。为此使用的任何方法都会在某个时刻将行/特定值传递给 SQL。
您可以做的是从数组创建一个表,并将该临时表与大型表进行比较以进行验证。不过,确定这是否更快需要进行一些测试。
There won't be a way via powershell (or any other method I am aware of) as SQL Server can't accept a table as an input parameter in a query. Any method you use for this will at some point be passing a row/specific values to SQL.
What you COULD do is create a table from your array and compare that temp table to your large table for validation. Determining if this is faster will need some testing, though.