1

Topic: Switching between different databases

I use Recorder for my personal records and have become the records officer of the London Bat Group who also run Recorder.  I am running Recorder 6.17 under Windows XP with SQL Server 2000.  I am aware that you can attach/detach databases to deal with this scenario but would like some precise instructions please.  Many thanks in advance.

2

Re: Switching between different databases

When I did the Recorder 2002 to Recorder 6 data transfer for the London Bat Group I supplied them with a SQL Server 2005 Express database. This can’t be used with an MSDE/SQL Server 2000 installation, however, if you install SQL Server 2005 or 2008 Express alongside MSDE, you will be able to use that for both your personal data and the LBG data. SQL Server 2005 Express is a little easier to install with Windows XP but, in that, the database size is limited to 4 GB whereas in SQL Server 2008 Express the limit is 10 GB. SQL Server 2005 and 2008 Express are free downloads from Microsoft but there are a lot of versions to choose from. http://www.recorder6.info/ should help you select an appropriate version but download and install one that includes the SQL Server tools. The procedure for swapping from MSDE to SQL Server Express is very similar to swapping from MSDE to SQL Server 2000 – the instructions for which are in the Network Installation Guide (page 10) which is available from http://jncc.defra.gov.uk/page-4595 , except that you should use the SQL Server 2005/8 tools, called Management Studio Express, instead of Enterprise Manager, the SQL Server 2000 tools. Note that if you copy and paste the query in point 11, you often need to re-type the quotes before it will run. The R6 database will be in something like C:\Program Files\Microsoft SQL Server\MSSQL$RECORDER6\Data in an MSDE installation. In SQL Server 2005 Express, it will be in C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data.

You will need the SQL Server tools to swap databases. Start Management Studio Express by selecting Start – All Programs – Microsoft SQL Server 2005/8 – SQL Server Management Studio Express. Note that this may vary depending on how it gets installed on your system. At the ‘Connect to Server’ dialogue box click ‘Connect’, assuming the Server name defaults to your SQL Server instance. In the Object Explorer hierarchy on the left, click the + beside ‘Databases’ to expand that node, then
•    Detach the Recorder 6 database, NBNData, by right clicking it, selecting Tasks and Detach, then clicking OK.
•    Rename the Recorder 6 database, NBNData_Data.MDF, and the associated log file, nbndata_data_log.LDF.
•    Copy in the .MDF and .LDF for the other database, although it isn’t essential to copy in the .LDF. If there is no .LDF when you attach a database, SQL Server will create one for you.
•    Attach the other Recorder 6 database by right clicking ‘Databases’ in the Object Explorer hierarchy on the left in SQL Server Management Studio Express, and selecting Attach. Use the add button in the dialogue box that appears and navigate to where NBNData_Data.MDF is stored, select it and click OK and OK again. You won’t be able to use Recorder 6 again until the database is attached. If the attach fails, try it without the log file.

When you run Recorder 6 you will now be accessing the other database.

If you are loading the other database from a backup, typically NBNData.bak, detach your database and take a copy of it then re-attach it, or take a backup and secure it. Place the backup of the other database in the backup location, usually C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup in SQL Server 2005 Express, and restore it.

Sally Rankin, JNCC Recorder Approved Expert
E-mail: s.rankin@btinternet.com
Telephone: 01491 578633
Mobile: 07941 207687

3

Re: Switching between different databases

Many thanks for the post.

I have seemingly successfully installed SQL Server 2005 and SQL Server Management Studio Express.  Using the latter and following the instructions in the Network Installation Guide on page 10 (from http://jncc.defra.gov.uk/page-4595), I have seemingly successfully reached step 10 but on step 11 receive the following message:

Msg 15291, Level 16, State 1, Procedure sp_change_users_login, Line 108
Terminating this procedure. The User name 'NBNUser' is absent or invalid.

which suggests that I have not created the user properly.  The NBNUser appears under the security/logins tab.  Under user mappings, I ticked NBNData and receieved another error message:

Create failed for User 'NBNUser'.  (Microsoft.SqlServer.Express.Smo)

ProdName=Microsoft+SQL+Server&ProdVer=9.00.5000.00&EvtSrc=Microsoft.SqlServer.Management.Smo.ExceptionTemplates.FailedOperationExceptionText&EvtID=Create+User&LinkId=20476
User, group, or role 'NBNUser' already exists in the current database. (Microsoft SQL Server, Error: 15023)

Any help much appreciated.

Derek

4

Re: Switching between different databases

I'm not sure, but it seems likely that the problem is to do with the new installation's NBNUser not being linked to the NBNUser in the old database.

Try the SQL here http://forums.nbn.org.uk/viewtopic.php?id=1483

If I am right, you may only need to execute the final line of the code, but I don't think it will hurt to run all of it.

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

5

Re: Switching between different databases

Many thanks.

I now seem to be up and running again.

Now to switch databases ...

6

Re: Switching between different databases

My database of personal records is working fine but I cannot switch successfully to the LBG database.

I have restored the LBG database and within Management Studio can successfully run queries, which suggests the database is fine.  However, when I try to open the Recorder application, I get the following message:

Cannot open database “NBNData” request by the login.  The login failed.

I have looked at the NBNUser properties and they are identical under
Databases>NBNData>Security>Users>NBNUser

I also looked at the NBNUser properties under
Security>Logins>NBNUser>User Mappings
and found that the NBNData database is not mapped to this user.
I tried to ticking the box but received the message
'User group or role NBNData already exist in the current database'

Any help much appreciated

7

Re: Switching between different databases

Again, not sure, but I think maybe you have to remap the NBNUser every time you switch to a different database using the final line of the code in the link above

Rob Large
Wildlife Sites Officer
Wiltshire & Swindon Biological Records Centre

8

Re: Switching between different databases

Many thanks.

It fixed the problem and the user mappings look fine now.