I know how to add additional extensions to SQL Server Management Studio, to have them treated just like .sql files. But, when opening them, a new instance of Management Studio is created.
I also see numerous issues posted about double clicking on .SQL files and getting them to open in the existing instance of SQL server. This already works for me.
What doesn't work is the additional extensions I have added. I'm using .PRC. All of the fixes propose changing various registry settings, all which are related to the default .sql extension.
I don't see see how any of these fixes can be applied to make other extensions work or if there is anything else I can do to solve this?
EDIT:
What i've done so far...
Copied over all the same settings from [HKEY_CLASSES_ROOT.sql] to [HKEY_CLASSES_ROOT.prc].
Checked all the settings mentioned in the article on sql server central to fix this issue for .SQL extensions.
Configured SSMS file type .PRC with editing experience "SQL Query Editor".
I even tried creating a batch file to open the file for me:
"c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\ssms.exe" /dde %1
Even the 4th thing I tried opens a new instance, although this is the same call that is configured in the registry for sqlweb.sql.9.0.
I resolved problem of opening PRC file by double click. I simply exported this key from regedit
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.sql
Modified this file to look like this
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.PRC]
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.PRC\OpenWithList]
"a"="ssms.exe"
"MRUList"="a"
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.PRC\OpenWithProgids]
"ssms.sql.11.0"=hex(0):
"ssms.sql.12.0"=hex(0):
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\.PRC\UserChoice]
"Progid"="ssms.sql.12.0"
And applied it over registry. The original PRC key I backuped and removed from registry before I applied that new keys. Now PRC file is opened by double click on PRC file in opened instance of SSMS.
But highlighting doesn't work still for me :(
You seem to be going through a lot of hassle to deal with your source control system. Have you considered making your source control system recognize a different extension for procedures, tables, views, etc. which will prevent you having to make these registry changes on every developer's computer?
.proc.sql -> stored procedure
.view.sql -> view
.fn.sql -> function
etc. etc. Surely your source control system can handle longer extensions that contain ., and now Management Studio will behave properly with all your file types.
Related
Whenever I open up SSMS (SQL Server 2012), I get all of the scripts that I had open in my previous session. This includes both saved queries and any unsaved queries, which are listed as SQLQuery1.sql, SQLQuery2.sql, etc.
I can't seem to find where these "unsaved" queries are being saved. I've checked Documents\SQL Server Management Studio\Backup Files\ (and every other directory in that vicinity). I've also checked the C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\ directory and subdirectories (as best I could). Finally, I did a complete search on my computer for the filename SQLQuery1.sql and it turned up nothing (not that I trust the Windows search function in file explorer).
In case it changes things at all, I also have installed the Redgate SQL Prompt add-on for SSMS.
Any other suggestions?
Thanks!
It's very simple :)
Create new query, then right click on the tab and then choose Open containing folder option.
For example, I got C:\Users\PKuderov\AppData\Local\Temp folder and my SQLQuery4.sql is named ~vs3C67.sql.
So #BenjaminSmith is right but these files have unique temporary names. Until you explicitly save them where you want. It seems they survive ssms reload and you can further filter them by .sql extension and Date Modified.
How about the TEMP folder? Try searching for %TEMP% from your start menu and searching in there.
I got my saved query in the following way.
I made another query and selected to save it.
It popped out the save as dialogue box from where I got all the things which I required.
I copied the file path which was "C:\Users\Shafiq Ur Rehman\Documents\SQL Server Management Studio"
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'm trying to open an old MS Access 2000 Database that was working on windows XP, so that i can migrate the old DB in a new application. The DB was created by the previous old WPF application and I need to find a way to open it. I installed MS Access 2000 and used a program that generated the right password for the db but there is still this message that pops up:
You do not have the necessary permissions to use C:/pathToDB.MDB object. Have your system administrator or the person who created this object establish the appropriate permissions for you.
Is there a way to solve this problem?
Many thanks.
Earlier versions before 2007 had something called as the MDW (Microsoft Access Workgroup) file with the MDB .
If you cannot find this, you can create one. To create this file, first create a new shortcut Right click New > Shortcut>. When asked type the location of the item. You will need to enter the following, replacing MDB/MDW> to where your files are located and the version of Office you are using. It may be worth opening notepad so you can get the path right and then copy and paste.
"C:\Program Files\Microsoft Office\Office14\MSACCESS.EXE" ".mdb" /wrkgrp ".mdw" /user
Replace Office14 with your version of Microsoft office that is installed. To find this, browse to “C:\Program Files\Microsoft Office\ and note the “Office” folder.
Use this new shortcut to open your file. It should hopefully sort it out.
delete the .ldb file and this should solve your problem. The .ldb file is created when a new session is created. If the program crashes, the .ldb file will not be deleted.
Hope this helps you.
Just provisioned a new server running IIS and Server 2012 and SQL Server 2012. I also installed SQL Server Management Studio tool so I can quickly inspect databases without the need to open a remote connection.
When I browse an ASP.NET sites remotely, I get a Just-in-time debgugger exception dialog when an error is encountered in addition to the yellow screen. The dialog stays up on the server and piles up unless I RDP and manually close all the dialog boxes.
The only way to disable this is by removing Visual Studio Shell 2010 (integrated) using the control panel. The side effect is that I can no longer use SSMS.
Most of the available solutions are outdated or don't work. The registry settings are no longer applicable and most articles concerning this issue are old. Microsoft's official documentation is a rat's nest of broken links. Moreover, many users are confusing IE's script debugging dialog with this issue. Although they are related and similar, this specific issue is tied to Visual Studio's runtime environment.
Any ideas?
ASIDE: I can't believe Microsoft has this "feature" on a product that is installed on a production server. I am just floored by the incompetence of a multi-billion dollar corporation. I've seen my question asked since at least since 2005 with no official solution that works. I just have to ask one last time for sanity checking. I want to make sure I'm not the one who is "thick" in the head here.
To disable Just-In-Time debugging by editing the registry
In the Start menu, click Run.
In the Run dialog box, type regedit, then click OK.
In the Registry Editor window, locate and delete the follow registry keys:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\DbgManagedDebugger
If your computer is running a 64-bit operating system, delete the following registry keys also:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\WindowsNT\CurrentVersion\AeDebug\Debugger
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework\DbgManagedDebugger
Take care not to accidentally delete or change any other registry keys.
Instead of deleting it, you can also just (temporarily) rename the AeDebug key for the bitness of your choice to something else, e.g. AeDebug-disable!
For server 2012, IIS, and SSMS 2014 we tried all three registry three deletions and those did not work.
What did work was old school renaming the JIT Debug executable.
Renamed these files.
C:\WINDOWS\system32\vsjitdebugger.exe
C:\Windows\SysWOW64\vsjitdebugger.exe
Renamed this folder
C:\Program Files\Common Files\Microsoft Shared\VS7Debug
As a follow-up to nfox's answer, I've created a registry file that you can simple use instead of searching manually through regedit.exe.
1.) Copy this script to your clipboard:
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug]
"Debugger"=-
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework]
"DbgManagedDebugger"=-
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug]
"Debugger"=-
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\.NETFramework]
"DbgManagedDebugger"=-
2.) Save it to a file with the .reg extension:
E.g. to a file named
C:\Users\<user name>\Desktop\DisableJit.reg
3.) Double click the file
After confirming the appearing message box, the keys are getting deleted.
5.) Alternatively: Download file
If this is too much effort, you can download the registry file from here:
disable-the-just-in-time-debugger-windows-64-bit.reg
disable-the-just-in-time-debugger-windows-64-bit.zip (As a ZIP)
Download and then double-click it.
This tip was simply taken from the MSDN article "Just-In-Time Debugging in Visual Studio".
The syntax on how to delete registry keys via a .reg file was taken from the MSDN KB article "How to add, modify, or delete registry subkeys and values by using a .reg file".
You should be able to disable Jist-In-Time debugging using the Debug options dialog inside Visual Studio. The registry keys are also well documented here.
See:
http://msdn.microsoft.com/en-us/library/5hs4b7a6.aspx
Aside: I think it's not a wise thing to install a management studio on a production server. This is what management workstations are for. Remote connections from a management station can be pre-configured and stored so that it doesn't take much effort. That way you can keep your production environment clean.
Installation of SSMS 2012 alongside any other existing SSMS installation, such as SSMS 2008 R2 has a problem with setting the default program for opening .SQL files to the new SSMS 2012 version.
Dragging .sql file to the query window works successfully. However, when a user double clicks on the .sql file a new instance of 2008 R2 can open as the .sql associated entry. Changing with Default Open With makes no difference when doubleclicking on new files. Additionally, altering the command line script for the opening can perhaps achieve changing the .sql to opening in SSMS 2012, but it still causes repeated instances of ssms instead of using the existing instance (causing additional load and memory usage).
Adapted from this post on how to how to fix .sql file not opening with SSMS 2008, you should start by opening up the registry (regedit)
Go to HKEY_CLASSES_ROOT\.sql and change the default value to ssms.sql.11.0 (SSMS 2012 is v11 of the product). This tells your computer the application string it should look for when trying to open files of type .sql
The registry takes that name you just entered and then looks up what to actually go do in another registry setting.
Go HKEY_CLASSES_ROOT\ssms.sql.11.0\Shell\Command and change the default value to:
"C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\ssms.exe" "%1" /dde
Turn your computer off and on again for good measure.
If it still doesn't work for whatever reason. Right click on any SQL file. Go to Properties and click to change the file it opens with. You may have two SQL options available. Try one then the other.
To change to default entry I utilized an application that displayed the DDE (dynamic data exchange) values. I personally used FileTypesMan.
I then changed the command line for SSMS to:
"C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\Ssms.exe" /dde "%1"
The reason a new instance is always opened with editing seems to be that windows needs to associate the file with a program so that it can identity if the existing program is running and use this instance. This seems to be achieved by using DDE. /dde indicates that the command line should use DDE. "%1" passes the first string (ssms.exe path) to the DDE protocol for usage as a parameter.
DDE Message: was kept at the SSMS 2008 R2's value I found: Open("%1")
DDE Application: Change the Application to ssms.11.0
Why? This was the difficult part. Where is this found? I could not find a tool for displaying the DDE application name. What I found was when I reviewed the registry editor that sqlwb.sql.9.0 is the entry to open a new .sql file with 2008 R2. This matched the registry entry for sqlwb.9.0 that SSMS 2008 R2 entry was showing before I started making my changes in FileTypesMan. I removed the .sql and found that the HKEY_CLASSES_ROOT had an entry for ssms.sql.11.0 .
= File association now set to new installation, and if SSMS.EXE is open, it should use the existing instance with no additional work.
Tip: To further speed up the initial load if you don't have it open, you can use other command line options on the load. Just go to the RUN dialog and type: ssms.exe -? for a list of startup parameters. I personally use -nosplash to eliminate the splash screen load.
Additionally, I use SSMSBoost, the single greatest tool I've had to help with using SSMS daily (basic code formatting, snippet w/cursor placement, preferred connections setup, full keyboard shortcut programming (along with the option for multiple steps in once shortcut, ie basic macros". Andre and his team are extremely responsive to new ideas in their forum, its very much developers helping improve other developer's life.
For SQL 2014 you can use the following *.reg-file (for 2012 replace the 12 with 11 and for 2016 (I guess) with 13) :
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\sql_auto_file]
#=""
"EditFlags"=hex:00,00,00,00
"FriendlyTypeName"="SQL"
[HKEY_CLASSES_ROOT\sql_auto_file\shell]
[HKEY_CLASSES_ROOT\sql_auto_file\shell\open]
[HKEY_CLASSES_ROOT\sql_auto_file\shell\open\command]
#="\"C:\\Program Files\\Microsoft SQL Server\\120\\Tools\\Binn\\ManagementStudio\\Ssms.exe\" /dde \"%1\""
[HKEY_CLASSES_ROOT\sql_auto_file\shell\open\ddeexec]
#="Open(\"%1\")"
[HKEY_CLASSES_ROOT\sql_auto_file\shell\open\ddeexec\Application]
#="ssms.12.0"
[HKEY_CLASSES_ROOT\sql_auto_file\shell\open\ddeexec\Topic]
#="system"
I had this same issue. Using "restore file associations" in ssms 2012 had no effect. I was able to resolve it by right clicking and choosing "open with" -> choose default program. Now I know you've said this didn't work, but there is a trick. Rather than selecting the pre-provided icon for ssms 2012, choose browse and go to c:\program files(x86)\Microsoft SQL server\110\tools\binn\managementStudio\ and click on ssms.exe. Click open, click ok. Once I did this, ssms 2012 was the default, and double clicking more .sql files loads into tabs in the same instance.
Another solution: https://stackoverflow.com/a/24945327/813599
I went looking for a more proper way to link to other Q/A's and couldn't find it after 15 minutes of searching... would love to be educated and will edit this out if so.
I was having a similar but slightly different issue. I wanted to open .sqlplan file in a new tab in SSMS 2014. I tried all of the above but none of them worked.
Looking at the registry, I found that ssms.sql.12.0 has "DdeExec" node, while ssms.sqlplan.12.0 does not.
enter image description here
So I export the "DdeExec" node from ssms.sql.12.0 and rename sql to sqlplan, then import it back in. After that, I was able to open .sqlplan file in a new tab.
Here is the registry file:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\ssms.sqlplan.12.0\Shell\Open\DdeExec]
#="Open(\"%1\")"
[HKEY_CLASSES_ROOT\ssms.sqlplan.12.0\Shell\Open\DdeExec\Application]
#="ssms.12.0"
[HKEY_CLASSES_ROOT\ssms.sqlplan.12.0\Shell\Open\DdeExec\Topic]
#="system"
Management Studio 18:
"C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Ssms.exe" /dde "%1"