AutoHotkey:尝试发送 sql 语句时如何修复 "this line does not contain a recognized action"?

AutoHotkey: How to fix "this line does not contain a recognized action" when trying to send an sql-statement?

我目前正在尝试编写一个粘贴 SQL 代码的 Autohotkey 命令,但我只收到此消息:

Error at line 3. Line Text: Create table #tmp (
Error: This line does not contain a recognized action.
The script was not reloaded; the old Version will remain in effect.

此消息还有一些变体。

我已经尝试过使用 SendRaw 或 SendInput。即使转义字符 ´ 也不起作用。也不用引号引起来。我已经没有任何线索了。

:*:sql::
(
--drop table #tmp 
Create table #tmp (
    Refnr int identity (1,1) not null, 
    row1 varchar(8000) null, 
    number int null 
    )
insert into #tmp (row1, number)
select top 20 row1, count(*) from tableA 
group by row1 
order by 2 desc
select * from #tmp order by 3 desc
)

好吧,我预计它会发送 SQL-声明,但我只是收到与上述错误类似的错误。有时它指的是行 "Create Table #tmp(",有时指的是 "insert into #tmp (row1, number)"。我不知道该怎么办。 有没有人知道并可以帮助我解决这个问题?

您需要注意收尾brackets/parentheses。您可以使用 back-tick ` 字符对文本中的字符进行转义。

例如:

:*:sql::
(
--drop table #tmp 
Create table #tmp (
    Refnr int identity (1,1) not null, 
    row1 varchar(8000) null, 
    number int null 
    `)
insert into #tmp (row1, number)
select top 20 row1, count(*) from tableA 
group by row1 
order by 2 desc
select * from #tmp order by 3 desc
)