将文本文件中的输入用于 WHERE 子句 [英] using input from a text file for WHERE clause
本文介绍了将文本文件中的输入用于 WHERE 子句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个文本文件中的员工姓名列表.
I have list of names of employees in a text file.
我不想一个一个地搜索每个名称,而是想在我的数据库中搜索一次文本文件的所有名称.比如:
Instead of searching each name one by one, I want to search my database once for all the names of the text file. Some thing like:
select emplayeeID, Salary from employees where employee-name in "C:\myfile.txt"
有可能吗?如果是,那么它的 SQL 命令是什么?谢谢.
Is it possible? If yes then what would be the SQL command for it? Thanks.
推荐答案
是的,使用 OPENROWSET with BULK.不过,您需要一个格式文件.
Yes, use OPENROWSET with BULK. You need a format file though.
select
E.emplayeeID, E.Salary
from
employees E
JOIN
OPENROWSET (
BULK 'c:\myfile.txt',
FORMATFILE = 'c:\myfileformat.txt'
) B ON E.name = B.name
这篇关于将文本文件中的输入用于 WHERE 子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文