I'm a sql server developer, in our field it's common to compile many sql code statements into a single script, but if we want to test just one statement in the script, we can highlight it and click execute.
I'm trying to make an ahk script to select/highlight just one sql SELECT statement, hopefully targeting the statement that the cursor is currently closest to.. for example, if I add a column or a where criteria or a new join, it would be cool to hit a key combo and select the text of the sql statement that I just edited, without having to manually click and drag to select it.
I constructed a regular expression, but ahk doesn't seem to be able to select text based on regular expressions.
Code: Select all
i)select\s+.*\s+from\s+.*\s+(join\s+.*)*\s+(where(\s*.+\s*(AND|OR)?)+)?(\s*.+\s*)\s*(go|;)
here's some fake sql for testing
Code: Select all
use dealers
GO
SELECT
*
from dbo.dealer_stone_price_sources join
where 1=1 and
2=2;
CREATE TABLE dbo.dealer_stone_price_sources
(
id INT IDENTITY(1,1) NOT NULL PRIMARY KEY,
dealer_id INT NOT NULL REFERENCES dealers(id),
name nvarchar(50) NOT NULL,
[description] nvarchar(255) NULL,
[enabled] BIT NOT NULL DEFAULT (1),
created_date SMALLDATETIME NOT NULL DEFAULT (GETDATE()),
created_user_id INT NOT NULL,
last_updated_date SMALLDATETIME NOT NULL DEFAULT (GETDATE()),
last_updated_user_id INT NOT NULL
)
GO
Usarian