While doing development in SQL Server Management Studio (SSMS), I frequently want to check the properties of a number of index on a specific table from within the Object Explorer:
Pulling up the index properties to see the columns included in the index, one can double-click the index name in Object Explorer, or alternatively use the Menu Key and then using Up to select Properties, and then hitting Enter.
I checked the SQL Server Management Studio Keyboard Shortcuts list, but did not manage to find the answer to my question.
Is there a one-key shortcut that could be used to pull up the index properties instead?
I have just tried to find any context menus registered in SSMS concerning Index in Object explorer, but unfortunately it looks like that it is 100% built dynamically. So it is impossible to assign a shortcut. Generally, you can assign shortcut on any command, that is registered as menu command in SSMS. But no luck here.
No, I don't believe so. Usually if someone wants that level of speed in accessing information about indexes, they'll just issue an sp_helpindex command in T-SQL or query sys.indexes for the information they want.
Related
A month or so ago I somehow managed to get a tiny widget showing in SQL Server 2008 where I could type the name of the procedure/table (never searched for anything else) and it would bring a list of matching items. I could then right click on the one I wanted -> Click (I believe) "synchronize" and it would bring the said item in the Object explorer, from where I could do whatever.
The widget I'm looking for was part of SQL Server and i was able to pin it bellow the Object Explorer.
I've no idea how I found it and where it is, but it's extremely useful for fast searching of objects.
It was NOT a Select or an SQL statement of any kind.
The SSMSBoost add-in also provides such functionality.
Maybe some screenhots are helping to remember...
As already mentioned by Creep, it could also be RedGate SQL Search:
Use the 'Object Explorer Details' window (F7).
SSMS -> View - > Object Explorer Details
I think it could be one of those (free) products : redgate sql search or dbforge sql search
I have numerous scripts to run in SQL Server.
Currently I've made many scripts which have been saved as file and can be loaded in SSMS when needed.
I want to know if we have any shortcut(bookmark) in SQL server to script files.
So far I've found nothing on internet. (note that creating stored procedures for these ad-hoc scripts is not an option)
By pressing Cntrl+K, Cntrl+W combination you can see the Bookmark manager.
Here you can see all bookmarks in locally saved sql queries.
Like in the below screenshot I have a bookmark for getLocationBasedMemberVisitsData.Sqlfile.
On how to add a bookmark
goto Edit>Bookmarks>toggle bookmark when you are inside your file with your edit cursor at the line you want to bookmark
P.S.: You can also create a folder hierarchy much like in browsers like Chrome
Store all needed files inside a single solution. Call it Utilities. Much like VS you can browse through the solution files using Solution explorer.
Caveat: The bookmarks on loose sql files are not persisted. So on a restart(close/open) for SSMS tool these are lost.
If you do need to persist bookmarks, create bound files i.e. store the files in a solution first.
Also the bookmarks in Management Studio are consist with Visual Studio.
Addendum:
Based on asker's comment
This just bookmark a line on a script. Is these any way to give these bookmarks a name?
You can rename both the folders as well as bookmark name by double clicking on it or by right click>rename option
On another comment
What do you mean by saving as as solution. I cannot find such option in SSMS. Are you referring to VS?
SQL server management studio like VS supports creation of Solutions(project) which are essentially collection of related queries/SP with connection information and other needed stuff.
To create a new solution press cntrl+shift+N. see screen shot below
Any bookmarks on solution files are sticky. Next time you open the solutions, bookmarks are presented back to you.
The SQL solution can be opened in VS too. The bookmark information along with other user information is stored in a *.ssms_suo file much like a *.suo file of VS.
It is a good idea to store all helpful files in a utilities solution which can be open all the time so that you can easily access it.
I think a Snippet is what you are asking for:
A Transact-SQL.code snippet is a template containing the basic
structure of a Transact-SQL statement or block. You can use snippets
as a starting point when adding statements in the Database Engine
Query Editor. You can insert the pre-defined snippets supplied with
SQL Server, or create your own.
more info here
In SQL Server Management Studio you could use menu -> Tools -> External Tools.
Do you use SQL Prompt? If so, this has a Tab History feature that lets you search for query windows, regardless of whether they have been saved or not.
If not, I'd use the snipppet feature that VV5198722 has referred to, or the Template Browser (invoked from the view menu).
I use SQL Server Express 2012 and have multiple SQL Server databases and sometimes it gets difficult to find out which is which. So I want to put a description on each database. But I am not able to find any such option in the management studio. Has anybody faced this problem and knows the solution
Got the answer now. We can use Extended properties.
Right click DBName in object explorer - > Properties -> Extended properties
In that I added "Description" under name and details under value. We can add more properties also if we want. Same can be done for Tables too
if you are using mssm you can use "Registered Server", that way you can name and describe them , even sort them in groups
In Toad for Oracle you can put the cursor on the name of a object and press F4 to open it's definition.
Is there anything similar in T-SQL / SQL Server Management Studio ides?
I have developed SSMSBoost add-in for SQL Server Management Studio and it does exactly what you want. The shortcut is F2
If you want the definition of an object, the procedure sp_helptext will give that to you. As for assigning it to a keyboard shortcut in SSMS, you can do so by going to Tools → Options → Keyboard → Query Shortcuts and assigning sp_helptext to one of the available slots. Once that's done, highlight the name of an object in your query editor window, hit the assigned shortcut and it should display the definition. As someone mentioned above, sp_help will get you different information (i.e. columns, indexes, constraints, etc) if the object is a table or a view. Luckily, the same process applies to sp_help!
I have a number of views in my SQL Server database.
How do I export these as CREATE VIEW scripts?
I tried to right click the database - script database as - create to - new query editor window, but it doesn't show my my views (or tables even for that matter).
Any ideas?
In SSMS, if you right click the DB -> Tasks -> Generate Scripts... - that will take you through a wizard.
You can run through the wizard and select your DB, then the views as AdaTheDev mentioned or you can right click on each query and generate a script directly.
I prefer another way, because always I edit the views to remove "not necessary script generated SQL syntax" (depends on the point of view :)).
Right click the view, Generate script, CREATE in, new window.
See screenshot below (sorry for german version, but should work anyway).
I tried to right click the db - script database as - create to - new query editor window, but it doesn't show my my views (or tables even for that matter).
The purpose of the menu you mentioned is only to create the empty database, without any tables, views or anything else.
If you want to script anything beyond the empty database, you have to use the wizard already mentioned in AdaTheDev's answer.
Maybe you receive empty page because source of VIEW was encrypted or removed.
In older SQL editions there was a trick - after creating VIEW (SQL Server compiled it) developer could remove source of VIEW statement to protect it from "deassemblation". In current editions there is possibility to encrypt source of VIEW statement.