I run a query very often and was wondering if it's possible to pin that query to the menu bar or toolbars of SQL Server for easy access?
Or does anyone have an alternate solution they use?
EDIT: Using Microsoft SQL Server 2012
Create a custom template and then you can easily access it from the Template Explorer in SSMS
To create a custom template
In Template Explorer, navigate to the node where you would like to
store the new template.
Right-click the node, point to New, and then click Template.
Type the name for your new template and then press ENTER.
Right-click the new template, and then click Edit. In the Connect to
Database Engine dialog box, click Connect to open the new template
in Query Editor.
Create a script in Query Editor. Insert parameters in your script in
the format . The data type and
value areas must be present, but can be blank.
On the toolbar, click Save to save your new template.
https://technet.microsoft.com/en-us/library/ms179334(v=sql.105).aspx
If you are not using one of those 3rd party tools, like redgate's SQL Prompt, then:
You could save your query as an SQL script,
When you launch SSMS,open the .sql file that you saved, connect to the server and select database that you want to run your SQL script on,
Now you can keep that tab open in a new horizontal or vertical tab if
you wanted to, switch to it anytime you want to run and press F5
It is not pinning to toolbar but well enough IMHO.
Related
Using Microsoft SQL Server Management Studio 18.
I have somehow lost the run button on my toolbar, along with the dropdown to select what database I am running my script against. I now have to work with a remote Azure database and would really like having that dropdown showing what context I am in.
This is what my toolbar currently looks like
I have tried Windows->Reset Window Layout and I tried clicking arrow at the far right of the toolbar->Add or Remove Buttons->Reset Toolbar, but neither of these seem to restore what I am missing.
How can I get back my run button and the Database selector dropdown to select what my script is running against?
You can follow those steps
View -> Toolbars -> [choose] SQL Editor
I have a SQL Server instance that I'd like to remove from the list that shows up in the available servers in Object Explorer. How do I do this?
Assuming you mean the dropdown list of servers when making a new connection you simply highlight the row in the dropdown and hit delete.
Here is simpliest way to clear items from this list.
Open the Microsoft SQL Server Management Studio (SSMS) version you want to affect.
Open the Connect to Server dialog (File->Connect Object Explorer, Object Explorer-> Connect-> Database Engine, etc).
Click on the Server Name field drop down list’s down arrow.
Hover over the items you want to remove.
Press the delete (DEL) key on your keyboard.
After avoid disasters for a few years, my luck finally ran out.
I had a few query windows open (one of them on our production server which I forgot about). Thinking I was on our dev server, I did all sorts of nasties and totally hosed our production database.
Any BKM's on how you folks keep this from happening?
All advice appreciated!
Open up SQL Server Management Studio
On the View menu make sure that Registered Servers is visible (alternatively hit CTRL+ALT+G
In the Registered Server panel expand Database Engine
Right-click Local Server Groups
Chose New Server Registration
Fill in your necessary server details and then switch to the Connection Properties tab
Click on the Use custom color checkbox
Select the colour to be used. I tend to chose bright-red for live servers and green for development environments.
Save your Registered Server.
Next time you open a query on this connection the status bar at the footer should show the colour you selected.
IMPORTANT: If you change the connection of a query window (option in the right-click context menu) the colour of the status bar does not change. Just be careful out there!
Specially for such case I have added "Important DB Alert" function into my SSMS add-in called SSMSBoost.
You can "save" your production and development databases and assign them different colors. Whenever you change your connection to "Important DB" you will be warned with additional tooltip, appearing in SQL Editor window.
The feature is described here:
http://www.ssmsboost.com/Features/ssms-add-in-preferred-connections
Or, to put it another way, where is SqlStudio.bin for SQL Server 2012? It doesn't seem to be in the place that would be expected by looking at this other SO question.
As of SQL Server 2012 you no longer have to go through the hassle of deleting the bin file (which causes other side effects). You should be able to press the Delete key within the MRU list of the Server Name dropdown in the Connect to Server dialog. This is documented in this Connect item and this blog post.
To be clear, since a couple of people seemed to have trouble with this for months: You need to click on the Server name: dropdown, and down-arrow or hover with your mouse until the server you want to remove is selected, and then press Delete. In this screen shot, I'm going to press Delete now, and it will remove the server ADMIN:SHELDON\SQL2014 from my MRU list. Note that because I merely hovered with my mouse, this is not even the server that is showing in the Server name: text box.
Note that if you have multiple entries for a single server name (e.g. one with Windows and one with SQL Auth), you won't be able to tell which one you're deleting.
Found it!
C:\Users\%username%\AppData\Roaming\Microsoft\SQL Server Management Studio\11.0\SqlStudio.bin
So the answer is as before: delete the file, or use some nifty PowerShell magic to edit it.
As for SQL Server Management Studio v18 it appears this file is now XML and you can edit it directly:
%APPDATA%\Microsoft\SQL Server Management Studio\18.0\UserSettings.xml
If you want to remove particular account or update password on Windows 10 then you can go to Windows Credentials in Credential Manager and update or remove related entry:
Control Panel >> Credential Manager >> Windows Credentials >> Microsoft:SSMS
This is the best way to clear these server names from the list.
Open the(SSMS) version. Mine is 18.
You should be right where you can see the server name dropdown list.
If not, you will open the Connect to Server dialog located in the File menu bar
Click on the Server Name field dropdown list.
"Hover over" (very important) the items you want to remove.
Pressing the delete (DEL) key on your keyboard should do the trick.
You're welcome
I am using SQL Server 2008 Express and Sql Server Management Studio 2008.
I am trying to associate a database table with a new schema.
I have created a new Schema by navigating to Security->Schemas in object explorer. I right clicked on the folder and created a new schema called 'People' and set the owner as db_owner. This new Schema now appears in object explorer.
I would now like to associate a table with this schema. I open the table in design view and click on the drop down list in the table Properties pane which contains the available schemas but my newly created schema is not visible.
I have tried refreshing everything throughout object explorer. Closing design view and reopening etc. but still it isn't there.
Am I doing something wrong?
Can anyone point me in the right direction please?
Sorted... in the most ridiculous way.
Apparently refreshing object browser at every hierarchical level is not sufficient.
I had to CLOSE sql management studio, then re-open it. The list of schemas had then managed to refresh and would allow me to associate my new custom schema with the table.
IMO this is rubbish.
Step 1:
Open New Query(or existing query window). Ctrl+Shift+R in query window. It will refresh the intellisence cache or
Edit > IntelliSense > Refresh Local Cache
Also check if IntelliSense is enabled in
Tools > Options > Text Editor > Transact-SQL > Enable IntelliSense
Step 2:
refresh F5 the Object Explorer.
it worked for me
Similar Answer on stack overflow
I am not following you when you say "open the table in design mode then click on the drop down list". I must be overlooking the list on my SQL Express.
Have you tried to change the schema via TSQL? The command is short:
ALTER SCHEMA "target schema" TRANSFER "source schema"."table name";
GO
Replace target and source schema with your schema names.