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

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. :-)

Related

How to change a stored procedure in VBA?

first I have to say: My VB and SQL is limited to the absolute basics. I'm still studying and don't really have a real idea how working with databases works in VB (or in general).
My current task for work is: I've been given a 10 year old program, coded by an ex-employee. This program is written and based on visual studio (a lot of windows forms) and is basically just a database management tool. It's supposed to show the stored data sets and give the user the option to import excel files and add data manually. The program worked pretty good so far, but some of the dropdown menus do not write the selected value into the database, but instead just leave the field empty. I'm supposed to fix that.
Now at first I thought it'd be really easy. Just look at the code of the save-button and check if the insert command contains the correct names of the database fields. After a bit of searching (the code is uncommented and basically a mess) I've found the function that gets called when the save button is clicked. This function takes an SqlDataAdapter and calls the method "InsertCommand" with a stored procedure and the database connection as parameters. Then it adds the different parameters and executes the procedure.
My problem is: Where can I find the stored procedure and how do I change it? I'm guessing there's simply a typo in there for the dropdown fields or something, but since I can't see it and actually don't really have a clue what a stored procedure is, I don't know how to proceed.
Sadly I'm not allowed to post the code, but I hope my explanations are enough for you guys to understand my problem. I don't want you to fix my problem, but rather point me in the right direction - am I completely wrong here, or is my route a good guess?
Thanks in advance, let me know if you need more information!
The Stored Procedure will be in the Database.
Assuming its an MS-SQL database, open Sql Server management studio, find the database, and look under the "Programmability" folder - you should see the stored proc in there.

Shortcut to execute last query in SSMS

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.

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/

How do I create queries to SQL Server tables via Visual Studio when no knowledge about SQL nor Linq?

Let´s be frank, my knowledge regarding SQL language is very low.
Nevertheless, my boss gave me the task to build a database application using the following tools: SQL Server and Visual Studio 2008; C#. I use the VS DataSet as a local mirror of the SQL Server.
And let´s be frank again, my understanding of the VS Query builder is also very small, I´m finding it quite confusing, actually. So no help to find from Query builder.
And my knowledge of Linq is even lower...
Perhaps I should mention that the deadline for the project is "aggressively" set, so I have no chance to learn enough about these things during the project. And I´m a bit stupid too, which is no help when it comes to challenges like this (on other occations it might be quite useful though)
With these permissions, what should I do (except for killing myself or retire) to be able to query my tables in a sufficient way?
Start learning. Look for another job at the same time. Obviously your boss is an idiot - giving you tasks to be not qualified for (or the story is a little different - would not be the first "specialist" trying to find employment that is clueless).
Sorry, I really dont know what else to say here - if yo do not know how to do your job, learn. If that does not work, then you can not do your task. Simple like that.
SQL Query takes a day to get started (on a beginner level). If you do not have this time - get your boss hire someone who has the knowledge.
keep a c# reference book handy. Also a book on sql or you can use sql books online. You can always google for your specific problem or use a forum to get answers. Be optimistic, quit whining and get to your task. All the best.
what type of task you want to do in SQL ? define in Detail.
and start working on the sql it's easy to understand.
there is a visual query designer in visual studio. that might be helpful. Open up server explorer, right click and existing database connection or create a new one and then right click to select 'New Query'.
In the query designer, you can add table and visually add conditions for joins, aggregates etc. and see the query being formed.
Use MS Access:
Start up Access, create a new DB.
Import your SQL Server DB to your new Access DB.
Select Create tab -> Query Wizard -> Simple Query Wizard (and it IS simple to use).
When the query is created, you can use the SQL code in your original SQL Server based application - but as SQL Server and Access aren´t 100% aligned, you might need to do some adjustments - google it up. Here is however a good page that will help you out.
Bonus is that it´s a good way to learn SQL "on the fly".

Data synchronizing with SQL Server Management Studio

I was just about to buy redgate.com's compare package when I came to realize it seems highly unlikely a task like this isn't something that can be performed from the Management Studio.
I have a development database and I have a live database.
I develop my application adding stored procedures, correcting small things in the data structure and maybe add some new tables.
Now I want the changes added to the live server. As it is unlikely I have kept 100% track of all of my changes I would of course like if it just new itself what I have changed.
Does anyone know what's best practice in Management Studio for this task? I mean it must be a task we all gets confronted with in larger projects.
If you do it with management studio it's all restricted to your own head. YOU will have to keep track of all the changes etc. I find that Redgates SQL Compare 8 and SQL Data Compare 7 does the trick. I recently moved the structure of a production database over to something totally different within minutes thanks to Redgate.
I have earlier tried to use Management Studio but it does not perform very well at complex tasks.
You really should be keeping your database schema in version control along with your source code.
What's wrong with it not being in the IDE? It has its own interface.
This tool save me hours a day. Not only because I dont HAVE to remember everything, but I then dont have to fix the production server if I missed something. I can work on multiple systems and push updates to each of them in a 10th of the time it would take me in the Management Studio.
This tool is by far the best 3rd party tool ive used for sql server. Its a godsend. A cheap one at that.
Just dont have the arrow pointing the wrong way ;-)
Okay I just bought Redgate :)
I have worked with it before so i can only agree that it is state of the art, I was just stunned to realize that Management Studio don't have anything that corresponds to this.
Thanks for the great answers!
Stackoverflow really is the pleace to ask these kinda things.