将数据从A列导出到基于B列的文本文件中
我希望使用来自Excel的数据来填充许多SQL脚本。
在一个列中有一个用户名列表。
在相邻的列中,有一个位置列表。
我有一个SQL脚本的模板,并且需要为每个位置生成一个TXT文件,并插入相关用户。
和此脚本模板:
locationa
Update usertable
set counduct_locked ='1'
中的用户ID (%locationa_users%);
locationb
更新可用的
set counduct_locked ='1'
中的用户ID (%locationb_users%);
输出将需要这样:
locationa
更新Usertable
set counduct_locked ='1'
中的用户ID ('user1','user2','user3','user4','user5');
locationb
更新可用的
set counduct_locked ='1'
中的用户ID ('user6','user7','user8','user9','user10','user11','user12');
它可以导出到一个文件,但每个位置都带有一个单独的脚本,或每个位置单独的文件。
I am looking to populate a number of SQL scripts using data from Excel.
In one column there is a list of usernames.
In an adjacent column, there is a list of locations.
I have a template of a SQL script, and I need a TXT file generated for each location, with the relevant users inserted.
For example, if this were the data set:
And this the script template:
LOCATIONA
update USERTABLE
set ACCOUNT_LOCKED = '1'
where USERID in
(%LOCATIONA_USERS%);
LOCATIONB
update USERTABLE
set ACCOUNT_LOCKED = '1'
where USERID in
(%LOCATIONB_USERS%);
The output would need to be like this:
LOCATIONA
update USERTABLE
set ACCOUNT_LOCKED = '1'
where USERID in
('User1','User2','User3','User4','User5');
LOCATIONB
update USERTABLE
set ACCOUNT_LOCKED = '1'
where USERID in
('User6','User7','User8','User9','User10','User11','User12');
It could either export to a single file, but with a separate script for each location, or a separate file per location.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我创建了一个具有一些公式的类似数据集。您可以激发自己的灵感,以获取所需的东西:
textjoin
基于“位置”和“ locationb”的用户列表,使用公式(= textjoin(“,”,true,true,c2:c6)< /code>)在值之前显示:
I have created a similar dataset, with some formulas. You can inspire yourself on this in order to get what you need:
TextJoin
based formula is used for collecting the list of users, both for "LocationA" and "LocationB", the formula (=TEXTJOIN(",",TRUE,C2:C6)
) is shown preceeding the values: