Friday, February 24, 2012

How to cosolidate databases of SQL Express from multiple installations?

1. install a SQL Express instance such as myexpress;

2. create some databases with tables such as db1 and db2;

3. Reinstall SQL Express with the same instance name "myexpress". I assume we need reinstall SQL Express myexpress again becuase of bad operations.

4. Open the myexpress by management tool but I can not see db1 and db2 databases but the datafiles and logfiles are in the data directory.

The question is what I need to do so I can consolidate exited databases so they can be seen in "myexpress" instance by management tool?

hi,

WhyHere wrote:

1. install a SQL Express instance such as myexpress;

2. create some databases with tables such as db1 and db2;

3. Reinstall SQL Express with the same instance name "myexpress". I assume we need reinstall SQL Express myexpress again becuase of bad operations.

4. Open the myexpress by management tool but I can not see db1 and db2 databases but the datafiles and logfiles are in the data directory.

The question is what I need to do so I can consolidate exited databases so they can be seen in "myexpress" instance by management tool?

reinstalling the database engine will actually overwrite your used master database... the master database contains the "registration" of each user database so that the "clean" master does not include those registrations... you can re-attach your existing database files via the

CREATE DATABASE xxx

ON (FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\xxx.mdf'

)

FOR ATTACH ;

statement... please have a look at http://msdn2.microsoft.com/en-us/library/ms176061.aspx for further info about it's synopsis... this will result re-registering a database from it's physical files...

BTW, overwriting the master database will also clean-up all logins information about all SQL Server and Windows NT principals.. associated (for SQL Server standard logins only) database users must also be cleaned/syncronized, for each user, via the sp_change_users_login system stored procedure, as reported in http://msdn2.microsoft.com/en-us/library/ms174378.aspx..

regards

No comments:

Post a Comment