My goal is to open SSMS from a shortcut on my desktop but I would like to specify more than one server. Currently this target is working well to open one of these servers.
"C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Ssms.exe" -S ServerName1 -E
But we have two production-level servers that I would like to open in the same SSMS window simultaneously, as I frequently need to connect to and query the other server at some point in my investigations anyway. I was thinking maybe something along the lines of these examples would work, but no luck:
"C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Ssms.exe" -S ServerName1 ServerName2 -E <-- This makes SSMS think it's supposed to open files.
"C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Ssms.exe" -S ServerName1, ServerName2 -E <-- This makes SSMS think it's supposed to open files.
"C:\Program Files (x86)\Microsoft SQL Server Management Studio 18\Common7\IDE\Ssms.exe" -S ServerName1 -S ServerName2 -E <-- And this simply opens the second specified server as the second overrides the first.
Nothing here: https://learn.microsoft.com/en-us/sql/ssms/ssms-utility?view=sql-server-ver15 says explicitly that I can't do this, but also does not say that I can. (Well, there isn't an example of this anywhere I have looked.) I was under the impression that because I was not providing databases or files with these parameters that it would be possible. I guess what I am trying to do is not practical and an analogy for this would be to specify a server and multiple databases, which does not make much sense.
Please help me understand the correct syntax for this shortcut if this is possible(or an equivalent workaround), and if this is not possible please inform me why this is perhaps bad practice or to be avoided. I really just want to see both of these servers in the object explorer upon SSMS loading. Perhaps a server group is the right solution?
Thanks for reading, any help is appreciated.
Related
I am using SQL Server 2008 (Express Edition).
I want to create a job which will delete all data from the all the table(>50) in the DB everyday at night 1:00.
Instead of Deleteting i decide to restore the DB from the Script.
It would have been easy by using SQL Server Agent, But this is limitation in SQL Server Express.
I figured out that we can create jobs "manually" by creating batch files and SQL script files, and running them via Windows Task Scheduler.
I have no clue what i have to write in bat file and sql file.This is my first time where i am working so deeply in SQL configuration. Can someone help please?
Name of the script which i need to restore is test.sql.
If any one has different approach , please share.
Thanks
Prat
Your batch files needs to look like this. Change the path to your .sql file and also put in the sql server info. You can read more about sqlcmd HERE. Also note the case on the switches -S and -i as it does matter.
sqlcmd -S <ComputerName>\<InstanceName> -i C:\test.sql
I am trying to downgrade a SQL Server 2014 database to a lower version (SQL Server 2012) by using the task Generating scripts found when right clicked on the database.
After I make the settings in order to generate the script, the server does that but when I'm trying to open the file (the script made) on a lower version instance of SQL Server, I get the following error.
System out of memory exception thrown
Could anyone provide some help? Thanks!
As suggested by #usr you can run the script from the command line using sqlcmd:
sqlcmd -S myServer\instanceName -i C:\myScript.sql
Alternatively you can download a trial edition of ApexSQL or Redgate SQL Compare (assuming you have not tried them already) and script over the changes using these tools.
The script is too big for SSMS (a shame!). Run it using SQL Server command line tools.
I find it easier to do this by using Redgate SQL Packager or the two compare tools. They can execute enormous scripts.
I generated a Script of a database of size appox. 8GB using SQL Server's scripting Service. (Schema and Data).
Now When I try to to open the generated Script file(.sql) , I get two different errors randomly.
Sometimes I get
And sometimes I get
In no specific order.
It is SQL Server 2008 R2 SP1 64 bit , Enterprise Edition.
Windows 2008 R2 Server SP2 64-bit , Enterprise Edition.
Any Idea what this is and how I can fix this? any suggestions or pointers in the right direction are much appreciated. Thank you.
8 GB is a very large SQL file, you won't be able to open such a big file in Management Studio without running into weird problems like those error messages you are seeing.
I suggest you use the sqlcmd command line tool to run your 8 GB file.
sqlcmd -S <db_servername> -d <db_name> -i <sql_filename.sql> -U <sql_username> –P <sql_password>
(sqlcmd is usually located in the folder C:\Program Files\Microsoft SQL Server\100\Tools\Binn for SQL Server 2008 R2)
I want SQL Server Management Studio (SSMS) 2012 to connect to a default server whenever I open any .sql file. How can I configure SSMS to do this?
You can add "-S servername" to the shortcut you use to run SSMS. Check out this page for more detail: http://blog.sqlauthority.com/2013/01/08/sql-server-using-ssms-commandline-parameters-guest-post-by-vinod-kumar-m/
These changes are not supported by Microsoft. They could cause your installation to break and/or produce trouble with upgrades and service packs. Perform them at your own risk.
You can do this by changing the command used to open .sql files. This requires a registry change -- the usual caveats apply. Open RegEdit and navigate to the key HKEY_CLASSES_ROOT\ssms.sql.11.0\Shell\Open\Command. The value (Default) should read
"c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\ssms.exe" /dde
Change this to
"c:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\ssms.exe" /s <server> "%1"
Where <server> is your desired default server.
Rename the HKEY_CLASSES_ROOT\ssms.sql.11.0\Shell\Open\Command\DdeExec key to _DdeExec to prevent the shell from trying to open the file using DDE.
This has two effects: opening a .sql file will open them with a connection to the server you specified, and opening a file will always open a new instance of Management Studio (since we removed DDE).
If you do not remove the /dde parameter, opening other files will reuse your SSMS instance. However, they will use the last opened connection in that instance, not your default, which I imagine is surprising and potentially catastrophic.
I am working with Management studio and I want to log in to databases located on another server in another domain. The only login I have for such is with Windows credentials.
I want to be able to log in via Management Studio on my local PC. I have found the only way to do so is using a command similar to:
runas /netonly /user:domain\username "C:\Progr...\IDE\Ssms.exe"
While this works, it isn't the easiest or nicest way. Is there a better way? Any way I can do it within Management Studio?
The only elegant ways to connect to a SQL Server in another domain but still use Windows Authentication are:
What you're already doing: runas /netonly
Connecting via remote desktop and opening SSMS locally on the remote server
In addition to the other answers you've received, you can also shift-right click on an executable or a shortcut to one and in the resulting context menu, there should be an option to run as a different user. I tried this on my Win 7 machine. I seem to recall that in XP, I had to install ShellRunAs for these options to show up.
You can get a graphical password prompt by downloading ShellRunAs or better yet, the entire Sysinternals Suite.
Store the executable(s) for ShellRunAs or the Sysinternals Suite in a location of your choice. I recommend:
C:\Program Files\Sysinternals
You can then enable a "Run as different user..." context menu option for all applications/shortcuts by running
shellrunas /reg
If you want to only enable this for SQL Server Management Studio, you can create a shortcut to it and pass the path the management studio like so:
"C:\Program Files\Sysinternals\ShellRunas.exe" "C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"
If you download the entire Sysinternal Suite, I would recommend you add the directory to your PATH environment variable.
Please note that you will need to adjust the paths above based on your SQL Server Management Studio version and whether you're running 64 bit or 32 bit Windows.