Shortcut to execute last query in SSMS - sql

Does there exist a shortcut to execute the last query run in SQL Server?
I can see the Query shortcuts in the Options menu under Environment (SSMS 2008) but nothing listed seems to describe this functionality.

I'm not sure that what you're specifically asking for is possible. However if you are willing to tackle your problem another way. I use a tool every day that might make what you are asking for possible, or at least as close as I think you might get.
SSMS Tools Pack is a plugin for SQL Server Management Studio that has a number or really great features. One that might interest you is the Current Window History. This is a window with all of the commands that have been run from this tab. While it doesn't do what you originally asked for, I feel like it is at least in the spirit of what you were trying to accomplish.

Related

Redgate SQL Prompt equivalent for PostgreSQL database

I'm starting at a new company after coming from a previous role where I could rely on Redgate's SQL Prompt with a MySQL environment. I'm now working with a Postgresql environment (SQL Workbench/J) and was wondering if anyone had come across any similar programs for Postgresql to make the query writing a bit less tedious and time intensive.
I'm aware of the CNTRL + Space option for suggesting columns/tables, hoping for something that automatically prompts.
Thanks!
You can use the dbForge Studio for PostgreSQL software to meet your needs, and this will help you to use this software in accordance with what is in the SQL Prompt program.
I hope the explanation I gave was useful to you.
A full-featured GUI tool for PostgreSQL is pgAdmin.
Among many other useful features, it has a query tool with code completion and suggestion.

SQL Server Management Studio 2012 - Query designer - keep query selected

not sure if anyone here can help me, but after more than 4 years of everyday work with SQL Mgmt Studio 2005 and 2008, I now also sometimes have to use the 2012 version, and there's one tiny change which freaks me out: in 2005 and 2008, I got used to edit a query in the query designer and after I finished and clicked ok, the query would remain selected in the code window so I could immediately execute it. Now, with 2012, they seem to have changed that and the selection is cleared after exiting the query designer. So hitting Alt-X right after the close will execute the whole code in the window (which already gave me a hard time yesterday).
Any idea if that is somehow configurable? I have already searched around but couldn't find anything (not even a similar question), but maybe it's just me again using the wrong search terms.
As far as I know, there is no option to enable/disable this. I checked the registry to be for sure and haven't seen any flag which tends to change this behavior. It would be a bit too much to change such a small behavior with an additional option.
I think your best option is just to adapt to the new behavior, if you like or not. :-)

Are there tools that can execute a SQL script one statement at a time?

When I have to run database migration scripts, I tend to exercise a large degree of paranoia and not run the script all at once like dbcli < migration.sql. Instead, I prefer to run the commands one-at-a-time. So far, I've just been using copy/paste which is miserable.
There has to be a tool that can do this kind of thing, but I'm having a hard time finding one using Google, Wikpedia, or StackOverflow (close but no cigar).
This is definitely something I could write myself, but it just has to exist already, doesn't it?
This really needs to be something that can be run from a command-line with a tiny bit of interactivity (like display the statement that will be executed, let you press e.g. ENTER to execute it, then show you the output if there is any) since servers usually don't have any GUI available.
My specific db target is MySQL but there's no need for such a tool to be db-specific.
Update
Meanwhile, I'm writing a utility in Java that will do what I want.
Oracle SQL Developer will run one line at a time as long as it's ended with a semi-colon.
You can connect to certain 3rd party databases with additional drivers (http://www.oracle.com/technetwork/products/migration/omwb-getstarted-093461.html)
You could try dbForge. There is a free Express Edition, but I can't quite tell from the feature comparison list if it allows you to step through arbitrary SQL scripts.
Emacs' SQL mode supports sending line by line, region by region and file by file.
Of course, you have to learn emacs, but it does do what you want.
Long ago, I wrote my own tool for this purpose, and have been using and perfecting it over time. Feel free to use it and offer suggestions for features, etc.
Flyway Teams Edition (commercial license) also supports executing statements one by one under Stream parameter. This is not an exact answer to your question, but it can at least give you information about existing tools.

How do I monitor how much time I'm spending on SQL Server?

Is there a table on MS SQL 2005 or 2008 servers that will show my boss how much work I'm doing?
Maybe something that would show how often my database tables/views/etc are being executed/queried against?
I would probably look at setting up a trace. You can read up on Data Access Tracing here.
Once you are done doing that, write a script that makes it look like you are working 24 hours a day and ask for a raise. Seriously if your boss is using your query history to determine how much work you are doing he is:
A real ball buster
Clueless
Get Mladen Prajdic's SSMS Tools Pack. It can keep a running history (in a database, on the local file system, or on a network share IIRC) of queries you are working on and/or executing, and you can customize how often it auto-saves for you. It won't tell you how much time you spent staring at the screen between edits or reviewing query results, but it should be a start.
Short answer: No.
There is nothing built in and immediatley avaliable within SQL Server that does this. There are any number of ways such functionality can be implemented, but none are simple or trivial, and a skilled DBA could run rings around 'em anyway.
This is what I use for looking up on what I have done during the day. This will be applicable to you ONLY if the the window title of whatever software, changes depending on what you are currently working on.
Eg: My Awesome SQL Software - Query1.sql
My Awesome SQL Software - newQuery.sql
My Awesome SQL Software - Results of Table 1
Manic Time will track individual applications + their window title.
http://www.manictime.com/

What do you use to write and edit stored procedures in Oracle?

There are many options for editing and writing Stored Procedures in Oracle; what is the best tool for you and why? (one tool per answer.)
Tool for Oracle Application Developers (TOAD), from Quest Software (formerly TOADSoft) has an excellent Stored Procedure editor with syntax highlighting, some autocomplete support (e.g. type in 'TABLE.' and the columns will appear), a nice Execute Procedure option that will show the results in a Grid or show DBMS output, and will also focus on syntax errors when you hit compile.
Note: The Freeware edition only allows 2 concurrent connections to the same Database Instance (even though the website says 5) - that means only 2 developers or DBA's can use it at the same time on the same Database. It also expires every 3 months but they're good at releasing updates.
I recently found the free Oracle SQL Developer.
nice looking GUI (makes you not poke out your eyes like the usual Oracle tools)
has many nice features, like showing tables filtered
lets you connect to multiple oracle instances at once
you can use sane configuration like ip:port username/password and do not have to use those strange TNSNAMES.ORA file based settings
you can set breakpoints and step through the code of stored procedures.
PL/SQL Developer from Allaround Automations.
I happily paid the $200 or so price for this.
Excellent IDE (+ good Intellisense, + debugging capability) with easy creation and editing of PL/SQL packages, SPs, Triggers etc
So much better than Toad.
Toad, from ToadSoft.com -> http://www.toadsoft.com/toad_oracle.htm
For someone like me who likes to work with a DBA tool like Microsoft's SQL Management Studio, it's a life saver.
As a professional PL/SQL developer I use (heh) PL/SQL Developer from Allaround Automations.
I've worked with TOAD for quite a long time but now it is quite overpriced comparing with PL/SQL dev. It has some advantages like knowledge base or ability to work with other RDBMS like SQL server but that's not a necessity for me.
But Notepad++ will always help to make occasional fix.
I always use PL/SQL Developer from Allround Automations.
http://www.allroundautomations.com/plsqldev.html
But some at our place swear by Toad
Use Oracle's own SQL Developer. If you are mainly working with Oracle, it does everything you'll need.
I use TOAD with our Oracle reports development, and I think that it's a good development tool. I normally toggle back and forth between a number of different Oracle instances and schemae, and I like the way that TOAD can display multiple windows for each instance/schema, or even more than one per schema.
TOAD takes a little while to learn and customize, but it's a worthwhile investment. The layout is similar to the Visual Studio .NET IDE with sidebars that can be anchored or rolled away. Tabs display different aspects of the Oracle schema, including procedures, jobs, stats, etc. And when I'm writing SQL, the editor uses color-coding and the error messages are Oracle-specific.
Toolset for Oracle (TOra) is a free, Open Source Database Tool very similar in scope (and look and feel) to Quest's TOAD
Compared to the freeware edition of TOAD, TOra allows multiple connections to different database instances at the same time, and has no concurrent connection limit (so any number of TOra users can be working on the same database instance)
I just used a standard editor (vim which then gave me syntax highlighting).
/Allan
I like SQL Developer from Oracle. Oh and its free! :)
I like Rapid SQL, you can debug SQL too
Notepad++ stays my favourite editor. I had to use SQL Developer in the past, it's not so "bad", but I encountered many problems with it. It proved very unstable so I wouldn't recommend it, or maybe only to test your procedures.
I use JetBrains IDEA (a Java IDE) to edit and SQL*Plus to execute. The advantages of using a tool with local version control, seemless integration into Source Version Control, advanced find and highlighting, great editing, 'live templates' and so on for me outweighs any advantage of having it 'database aware' (which with plug-ins you can get anyway). If I was coding up a complicated query I might fire up SQL Developer, but generally I prefer great text editing features.
I use Oracle SQL Developer - the latest version also has support for CVS and Subversion.
It has the bonus of supporting other database providers, too.
I have used this tool for 2 years and it has now settled down to be reliable.
I've used RapidSQL by Embarcadero on several different DB platforms, and it's awesome. It has an integrated step debugger, too. I haven't actually used it with Oracle, but I know it's supported.
Another vote for Oracle SQL Developer. It's free, it's stable and it does all the basics that I require.
With the mentioned SQL Developer you can even set breakpoints and step through the code of the stored procedure.
Yet another vote for Oracle SQl Developer. But TOAD works too.
A really good text editor with syntax highlighting (e.g. Textpad from www.textpad.com) and SQL Plus.
For me its, Oracle SQL Developer. The learning curve is very minimal if you have worked on IDEs like Eclipse or VS. You can set break points, read live values when you debug stored procs as you would do to code in eclipse/VS.
Ofcourse the UI is a bit sluggish at times but given that its free compensates the sluggishness.
I use Textpad, Clipmate and Quest SQLNavigator. The newer versions of Quest's SQLNavigator and TOAD are crap -- they tend to crash easily and don't play nice with XP/Vista/Win7.
I've spent hours with their tech support and they don't have alternatives.
You get no access to Quest programmers, but rather you get bogged down in their
trouble ticket process.
Quest needs to focus less on integration of different tools into one and selling you
promises that the next version will solve the instability issues.
They need stability.
This means cleaning up their existing codebase or starting over.
More competent programmers, fewer salespeople, fewer tech support people.
Fix the damn problems.
They focus on sales and it's an idiotic business strategy.
This seems to be a problem across the industry.
Quest's TOAD and SQL Navigator have become bloatware and will soon become abandonware
if they don't turn them around and make them more stable.
I copy and paste frequently between Textpad and Quest SQLNavigator because SQLNavigator
crashes and I lose all my sql code up to the point of crash.
I'll probably dump SQLNavigator once I find something more stable.
SQL Developer from Oracle
We have replaced all other tools at our (large well known) enterprise that has over 150 databases and it works just fine. It's not as good as TOAD but it is getting there, and (unlike TOAD) it's free.
SQL Developer also works well enough connecting to SQL Server