I can't seem to figure out how to set the default database in Sql Server from code. This can be either .Net code or T-Sql (T-Sql would be nice since it would be easy to use in any language). I searched Google and could only find how to do it in Sql Server Management Studio.
相关问题
- sql execution latency when assign to a variable
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
- NOT DISTINCT query in mySQL
相关文章
- Entity Framework 4.3.1 failing to create (/open) a
- Code for inserting data into SQL Server database u
- Connection pooling vs persist connection mysqli
- Delete Every Alternate Row in SQL
- Linux based PHP install connecting to MsSQL Server
- SQL Azure Reset autoincrement
- How do we alias a Sql Server instance name used in
- Is recursion good in SQL Server?
ALTER LOGIN
should be used for SQL Server 2005 or later:http://technet.microsoft.com/en-us/library/ms189828.aspx
sp_defaultdb
eventually will be removed from SQL Server:http://technet.microsoft.com/en-us/library/ms181738.aspx
Thanks Stephen.
As a note, if you are using Windows Authentication, the
@loginname
isYourDomain\YourLogin
(probably obvious to everybody else, but took me a couple tries.from: http://doc.ddart.net/mssql/sql70/sp_da-di_6.htm
If you're trying to change which database you are using after you are logged in, you can use the USE command. E.g. USE Northwind.
https://www.tutorialspoint.com/sql/sql-select-database.htm