I am using visual studio 2012 and im writing sql code in it. Is it possible to make a shortcut when i mark a text it will try to append that text to a SELECT * FROM statement so when i mark a table name and press ctrl + 1 it will select everything from that table
|
C#
Help with Visual Studio Shortcuts |
|
Sep 22, 2014 06:03 AM
(This post was last modified: Sep 22, 2014 06:04 AM by eXaByte.)
its a snippet of code 'SELECT * FROM ' and when i mark lets say a table name 'mytable' and i run this snippet of code with my defined combination it will select everything from that table
sorta like concatenating the snippet with the marked text and executing it
I wouldn't use "SELECT " to begin with. Please please please always name the columns you want from the query and only query the columns you are actually going to use. I can't tell you how many times I've seen on JOIN queries to return 100+ columns only for the developer to use like 5...
Sep 22, 2014 06:08 AM
(This post was last modified: Sep 22, 2014 06:09 AM by eXaByte.)
I am using * because i will use this shortcut on objects which i would not know their column names also i just want to know the method of how to do this my example code is irrelevant
(Sep 22, 2014 06:08 AM)eXaByte Wrote: I am using * because i will use this shortcut on objects which i would not know their column names Ah snap. I didn't consider that. Are you using MSSQL or MySql?
Sep 22, 2014 06:10 AM
(This post was last modified: Sep 22, 2014 06:13 AM by eXaByte.)
(Sep 22, 2014 06:09 AM)ShadowCloud Wrote: Ah snap.im using visual studio to write tsql code because my project files need to be synced with others (Sep 22, 2014 06:10 AM)eXaByte Wrote: im using visual studio because my project files need to be synced with others No I meant is the datasource MSSQL or Mysql? I might need some more background information on this... but what I was going to is that you could select the columns from the sys tables... Ctrl+K, Ctrl +B as per the above user should work well for you I imagine? (Sep 22, 2014 06:13 AM)ShadowCloud Wrote: No I meant is the datasource MSSQL or Mysql? my problem is not how to select the column names i just want to know the way how to be able to execute a statement when i have a piece of text which will represent the name of an object so that execute statement concatenates with the name without me having to write for example exec sp_helptext name_ of_my_proc but only select the name of my proc and pressing lets say ctrl+3 and it will automanticly execute 'exec sp_helptext name_ of_my_proc' (Sep 22, 2014 06:20 AM)eXaByte Wrote: my problem is not how to select the column names i just want to know the way how to be able to execute a statement when i have a piece of text which will represent the name of an object so that execute statement concatenates with the name without me having to write for example exec sp_helptext name_ of_my_proc If you use a global keyboard hook (in the same fashion as a keylogger I imagine) you'd be able to make pretty much any combination do pretty much anything? The snippet will work work adding the text in front of the name, don't think it will concat though. (Sep 22, 2014 06:26 AM)ShadowCloud Wrote: If you use a global keyboard hook (in the same fashion as a keylogger I imagine) you'd be able to make pretty much any combination do pretty much anything?it might not be possible with the built in functions of visual studio i thought it would be easy because this feature is built in the MSSMS and is quite easy and comfortable using it (Sep 22, 2014 06:32 AM)eXaByte Wrote: it might not be possible with the built in functions of visual studio i thought it would be easy because this feature is built in the MSSMS and is quite easy and comfortable using it O you are talking about the query shortcuts... Have a look at this: http://stackoverflow.com/questions/33646...xecute-sql Is that what you were after?
Sep 22, 2014 06:44 AM
(This post was last modified: Sep 22, 2014 06:47 AM by eXaByte.)
(Sep 22, 2014 06:38 AM)ShadowCloud Wrote: O you are talking about the query shortcuts...No. But i expect that my answer will be somewhere in the same menu What i want to do is this just in visual studio. the example you showed will execute whatever i selected in my example i will execute whatever i selected with a prefix command |
|
|



