为了尽量减少一次又一次地编写特定查询的工作量。我们如何动态传递可以在匹配或不匹配的数据库中搜索的特定关键字?
答案 0 :(得分:0)
以下是AutohotKey脚本:
编译以下脚本并运行它。 用法:在ms-sql窗口中输入qc#,它会要求您输入搜索数据库的关键字。键入关键字并输入后。它将键入整个脚本。执行它并看到魔法。
这是脚本:
:?*:qc#::
varQ =
(
SELECT
'select * from [' {+} s.name {+} '].' {+} t.name AS Table_Name,
c.name AS Column_Name
FROM
sys.columns c,
sys.tables t,
sys.schemas s
WHERE
s.name NOT in ('logs','legacy','cdc')
and t.name NOT LIKE '`%[0-9]`%'
and c.object_id = t.object_id
AND t.schema_id = s.schema_id
AND c.name LIKE 'xxx'
order by 1
)
Input, thename, v,{Enter}{Space}
StringLen, MyLen, thename
MyLen++
thename = `%%thename%`%
StringReplace, varQ, varQ, xxx, %thename%, All
SendInput {BackSpace %MyLen%}+%varQ%
Return