ssms

How can I change my default database in SQL Server without using MS SQL Server Management Studio?

妖精的绣舞 提交于 2019-11-27 06:01:19
I dropped a database from SQL Server, however it turns out that my login was set to use the dropped database as its default. I can connect to SQL Server Management Studio by using the 'options' button in the connection dialog and selecting 'master' as the database to connect to. However, whenever I try to do anything in object explorer, it tries to connect using my default database and fails. Does anyone know how to set my default database without using object explorer ? Alternative to sp_defaultdb (which will be removed in a future version of Microsoft SQL Server ) could be ALTER LOGIN :

Removing the remembered login and password list in SQL Server Management Studio

痴心易碎 提交于 2019-11-27 05:56:27
I've recently used our company's spare laptop (that has a general user set up) while mine was being repaired. I've checked the "Remember password" option in SQL Server Management Studio when logging in to the database. I need to clear the login and password information that I have used to prevent the next person that will use the laptop from using my login names and passwords. How can I do this? Robin Luiten Another answer here also mentions since 2012 you can remove Remove cached login via How to remove cached server names from the Connect to Server dialog? . Just confirmed this delete in MRU

How to see the values of a table variable at debug time in T-SQL?

不问归期 提交于 2019-11-27 05:54:59
Can we see the values (rows and cells) in a table valued variable in SQL Server Management Studio (SSMS) during debug time? If yes, how? That's not yet implemented according this Microsoft Connect link: Microsoft Connect kirby DECLARE @v XML = (SELECT * FROM <tablename> FOR XML AUTO) Insert the above statement at the point where you want to view the table's contents. The table's contents will be rendered as XML in the locals window, or you can add @v to the watches window. This project https://github.com/FilipDeVos/sp_select has a stored procedure sp_select which allows for selecting from a

Recover unsaved SQL query scripts

主宰稳场 提交于 2019-11-27 04:55:34
问题 How to recover the unsaved scripts if the SSMS crashes / unsaved tab gets accidentally closed? 回答1: Posting this in case if somebody stumbles into same problem. Googled for Retrieve unsaved Scripts and found a solution. Run the following select script. It provides a list of scripts and its time of execution in the last 24 hours. This will be helpful to retrieve the scripts, if we close our query window in SQL Server management studio without saving the script. It works for all executed

“Save changes is not permitted” when changing an existing column to be nullable

一笑奈何 提交于 2019-11-27 03:48:53
问题 I've got a SQL Database Table, which has 35 existing records. One of the fields in this table is called Name , nvarchar(100) , not null However, due to a recent change, I need to make this column nullable. When I change the column to allow nulls in SQL Server Management Studio, and go to save my changes, I get the following error: Saving changes is not permitted. The changes you have made require the following tables to be dropped and re-created How can I allow this to automatically be

SQL Management Studio won't open scripts on double-click

允我心安 提交于 2019-11-27 02:37:11
问题 I'm used to double-clicking *.sql script files to open them in SQL Server Management Studio. I recently upgraded to Win7, and now when I double-click a script file, SSMS opens with an empty environment. I can then use File/Open or File/Recent Files to open my script, but I would much prefer for it to just open whatever I double-clicked on like a normal application would. Any ideas what's going on? BTW when I double-click a script from the Solution Explorer in Visual Studio, it does open it

How do I grant read access for a user to a database in SQL Server?

江枫思渺然 提交于 2019-11-27 01:15:46
问题 I want to grant access to a user to a specific database with read and write access. The user is already available in the domain but not in the DB. So, how can I give them that access with creating a new user and password? Someone told me that it can be done with only specifying the user, domain & the DB that you want to give the user the access to without needing to create a new user and password. This is the old way that I was implementing. It works but it creates a new login and user rather

What is the T-SQL syntax to connect to another SQL Server?

☆樱花仙子☆ 提交于 2019-11-27 00:05:34
问题 If I need to copy a stored procedure (SP) from one SQL Server to another I right click on the SP in SSMS and select Script Stored Procedure as > CREATE to > New Query Editor Window. I then change the connection by right clicking on that window and selecting Connection > Change Connection... and then selecting the new server and F5 to run the create on the new server. So my question is "What is the T-SQL syntax to connect to another SQL Server?" so that I can just paste that in the top of the

How to remove “Server name” items from history of SQL Server Management Studio

岁酱吖の 提交于 2019-11-26 23:48:58
When trying to connect to a server in Management Studio (specifically 2008), there is a field where you enter the Server name. That field also has a drop-down list where it shows a history of servers that you have attempted to connect to. I would like to know: How to remove an individual item from that history. How to remove an item from the Login field history for each Server name. Thanks! 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

SQL Formatter for SQL Management Studio [closed]

依然范特西╮ 提交于 2019-11-26 23:21:08
I was wondering if there is a plugin/tool for SQL Server Management Studio that will format your SQL? I'm working with some large-ish stored procs that are a mangled mess of poorly formatted SQL and it'd be nice if I could just go "Select All -> Format SQL" Today I discovered Apex SQL Refactor. It is a free plugin. Integrates with SSMS. Downside is that it is an all or nothing process. It does not refactor as you type. Tao Late answer, but hopefully worthwhile: The Poor Man's T-SQL Formatter is an open-source (free) T-SQL formatter with complete T-SQL batch/script support (any DDL, any DML),