From my previous posts one can understand that it is possible to write SQL queries directly in command prompt with the help of SQLCMD utility.
Now let's assume we have typed a 'big' query and there is a typo there! Instead of going back and forth to edit it in command prompt won't it be easy if we are able to open the query in an editor and make the corrections there?
Yes its possible in SQLCMD. All we need to do is type ed and it will open up the last command/query in a text editor. FYI the default editor is Edit (the command line editor of MS DOS).
Step 1: Open up SQLCMD and connect to your SQLServer
Step 2: type any query of your choice
Step 3: type ed
Step 4: The query would have opened in the 'EDIT' utility of DOS. Once you are done with the change, save and exit from that.
Step 5: type go and press enter
Can I make 'ed' to open up notepad or any editor of my choice?
Yes it's possible.
Step 1: Open DOS prompt
Step 2: Type set sqlcmdeditor=notepad
Step 3: Open up SQLCMD and connect to your SQLServer
Step 4: type any query of your choice
Step 5: type ed
Step 6: The query would get opened in notepad. Once you are done with the change, save and exit from that.
Step 5: type go and press enter
Now let's assume we have typed a 'big' query and there is a typo there! Instead of going back and forth to edit it in command prompt won't it be easy if we are able to open the query in an editor and make the corrections there?
Yes its possible in SQLCMD. All we need to do is type ed and it will open up the last command/query in a text editor. FYI the default editor is Edit (the command line editor of MS DOS).
Step 1: Open up SQLCMD and connect to your SQLServer
Step 2: type any query of your choice
Step 3: type ed
Step 4: The query would have opened in the 'EDIT' utility of DOS. Once you are done with the change, save and exit from that.
Step 5: type go and press enter
Can I make 'ed' to open up notepad or any editor of my choice?
Yes it's possible.
Step 1: Open DOS prompt
Step 2: Type set sqlcmdeditor=notepad
Step 3: Open up SQLCMD and connect to your SQLServer
Step 4: type any query of your choice
Step 5: type ed
Step 6: The query would get opened in notepad. Once you are done with the change, save and exit from that.
Step 5: type go and press enter
Comments