Friday, October 30, 2009

Connecting to a Database without Entering Parameters Every time from SSMS

If you are using SSMS regularly, you know that you have supply database name every time. You can avoid this by supplying a default database for a user. However this is not recommended because in case that database is dropped or renamed, user will not be able to login to SQL Server and will receive this error.

Cannot open user default database. Login failed.
Login failed for user 'sa'. (Microsoft SQL Server, Error: 4064)

SQL Server Management Studio is executed from a exe called SSMS which resides by default at  "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe"

For this you can supply server name and database name as following.

"C:\Program Files\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\Ssms.exe" -S Dinesh-PC -D AdventureWorks2008

You can create a short cut with above values and when ever you click the short cut SSMS will database as AdventureWorks2008. However, problem with this is that, Object Explorer will not load objects unless you use conventional connect dialog box.

No comments:

Post a Comment