Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
When working in a query window in SSMS, primarily a "working development" window with several statements strewn about in various stages of testing/experimentation, it can be a pain (minor, but a pain nonetheless) to have to highlight the desired SQL before hitting F5.

I propose (here we go) 2 SQL execution shortcuts:

1) Execute from the cursor up and down all "connected" text. "Connected" meaning no all-white-space lines separating.
2) Execute ONLY the entire line the cursor is on.

For example, suppose the query window contained:

SQL
SELECT TOP 1 * FROM MyTable

SELECT <field list=""> FROM MyTable
JOIN <join this="">
LEFT OUTER JOIN <join that="">
JOIN <join the="" other="">
WHERE <criteria>
AND <more criteria="">
AND <yet more="">
GROUP BY <my groups="">

SELECT <some things=""> FROM MyOtherTable WHERE TransDate = '5/1/2007'
AND TransCode IN (1,2,3)

SELECT <and so="" on="" and=""></and></some></my></yet></more></criteria></join></join></join></field>


Putting the text cursor ANYWHERE in the MyTable query and pressing the (1) shortcut would execute that entire SELECT. And putting it anywhere on the 1st line of the MyOtherTable query would execute that SELECT without the TransCode criteria.

I think this could make for a speedier research/development session in SSMS.
Posted
Updated 4-Sep-11 19:04pm
v2
Comments
Simon Bang Terkildsen 2-Sep-11 19:24pm    
Is this a question?
Dr.Walt Fair, PE 2-Sep-11 23:36pm    
So, how do you do that? Or is that your have a question?
arathi_suresh 3-Sep-11 6:50am    
What is your question?
The_Leader 10-Sep-11 11:35am    
I think its not a question?
RDBurmon 12-Dec-11 6:46am    
aixxha , Please use Article menu to submitt this kind of article. My suggestion is that you must have add this article right away to "Tips and Trick" section found under Article Menu.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900