9 august 2012 10:59
I can't attach a database in SQL Server Management Studio for MS SQL Server 2008 R2. I try this:
But then I get:
This is obviously a UI bug. But maybe I can attach a database using some sort of T-SQL script?
9 august 2012 11:18Moderator
Run SSMS with the “Run as Administrator” option. Assign sysadmin role to the account you are using to attach the database. For more information, please see the following post:
Hope this helps.
10 august 2012 07:28
if you are facing problem using User Interface you can accomplish same using SQL Query.
CREATE DATABASE MyAdventureWorks ON (FILENAME = 'C:\MySQLServer\AdventureWorks_Data.mdf'), (FILENAME = 'C:\MySQLServer\AdventureWorks_Log.ldf') FOR ATTACH;
12 august 2012 17:20Moderator
You could use sp_attach_db to attach a database to a server.
The following example attaches files from AdventureWorks2008R2 to the current server.
EXEC sp_attach_db @dbname = N'AdventureWorks2008R2', @filename1 = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Data\AdventureWorks2008R2_Data.mdf', @filename2 = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Data\AdventureWorks2008R2_log.ldf';
For more information, please refer to http://msdn.microsoft.com/en-us/library/ms179877(v=sql.105).aspx.
Please remember to mark the replies as answers if they help and unmark them if they provide no help. This can be beneficial to other community members reading the thread.
- Marcat ca răspuns de Bogdan Verbenets 13 august 2012 13:43