Home | More About Me 
| ...MSDE - Microsoft Data Engine... |
What is MSDE ? Features of MSDE System Requirements of MSDE Installation of MSDE on the machine Working with MSDE databases Linking Database Example of MSDE (VB) Migration of SQL server database to MSDE database References on MSDE |
| Introduction |
|
This is an attempt to prepare a detailed knowledge base on Microsoft’s Data engine, which is abbreviated as MSDE. |
| What is MSDE ? |
|
MSDE i.e., Microsoft Data engine, is known as an alternative to Jet for building desktop and shared solutions. MSDE is a fully SQL server 7.0 compatible data engine for building distributed solutions that consists of the SQL server features, reliability and security. The code base written for MSDE need not be changed when migrated to SQL server 7.0.
This is an obvious question to anyone that why do we have to use MSDE database when we have other Microsoft’s options available with us like MS Access 2000 or SQL server 7.0. The reason is, Though the Access database is relatively inexpensive, they place limits on the database size and performance for concurrent users. SQL server 7.0 has much higher support for data size and concurrency, but it can be very expensive. The most important is if you write programs into Access, it is not easy to upgrade it to SQL server. So the advantage of MSDE is, Though it is the restricted version of SQL server, the data model is exactly the same as the SQL server. It does have a database size limitation, but it can be upgraded to SQL server without any change in the code. |
| Features of MSDE |
|
1. Though the MSDE is a data engine, it does not have its own interface for database creation or administration. But this can be achieved by the comprehensive interface of enterprise manager of SQL server 7.0. This is required only to test the MSDE solutions that are created using VB 6.0. The SQL 7.0 server (Developer edition) offers the Enterprise Manager for administrating, creating and managing the database objects, but its developer edition license doesn’t permit its distribution with custom solutions.
|
| System requirements for MSDE |
|
1. For developing and using MSDE solutions, client workstation must have office 2000 professional editions (or higher) installed.
|
| Working with MSDE databases |
|
As MS access uses Jet engine to create its databases, the MSDE databases uses MSDE as a data engine.
Communicating with Database: The database related operations add/delete/edit (DML operations) data from the available tables can be performed using Microsoft’s rich ADO library can be used to execute the SQL commands. For DDL statements, refer to this example below, http://msdn.microsoft.com/vstudio/msde/deploying.asp#database, in this DCL statement that creates the database is used. Deploying MSDE solutions: Since MSDE is free for distribution, it can be deployed along the Package and deployment wizard of VB 6.0. Visit below link to know more about it: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q231923 http://support.microsoft.com/default.aspx?scid=kb;en-us;Q234626 Any SQL server database can also be used as an MSDE database by performing the ‘Attach’ and ‘Detach’ SQL-DMO operations. To know more about these operations, please visit the following link: http://msdn.microsoft.com/vstudio/msde/deploying.asp#database Back up and Restore of database: Physical restore and backup of the database: When the MSDE server is on, the current data modifications or operations are done in the Driver:\MSSQL7\Data\ within the files YourDBName.MDF and YourDBName_log.LDF files. In order to take up the backup, you need stop MSDE server by clicking on ‘Mssqlserver – Stop’ option which one can find by right clicking the MSDE service manager icon in system tray. Once it shows red dot in the service manager, which means it has stopped its services, and closed the data related files. However, it may actually take some more time to do this operation (generally 10 secs). After that one can copy the YourDBName.MDF and YourDBName_log.LDF files physically in their respective backup folders. The change in this file can be noted by the change in the date and time of those files. Please visit below link for more information: http://www.vbpj.com/upload/free/features/vbpj/2000/14fal00/ss0014/ss0014.asp Programmatic backup of the database: The ‘BackUP’ object within the SQL-DMO object provides a source database name and target device to take the backup of the entire database. It will allow the user to make ‘complete’ backup or ‘differential’ (only that data is taken for backup which has changed after the last backup) backup. Please visit the following for more information: http://www.microsoft.com/office/ork/2000/five/75t2_6.htm (It’s a command line example) http://www.15seconds.com/howto/pg000945.htm Compress/Decompress Database: The database can be compressed/ decompressed by the T-SQL statements, The SQL statement could be like following, DBCC SHRINKDATABASE ( database_name [, target_percent] [, {NOTRUNCATE | TRUNCATEONLY}] ) Arguments: It shrinks the size of the data files in the specified database. database_name: Is the name of the database to be shrunk. Database names must conform to the rules for identifiers. For more information, see Using Identifiers. target_percent: Is the desired percentage of free space left in the database file after the database has been shrunk. NOTRUNCATE: Causes the freed file space to be retained in the database files. If not specified, the freed file space is released to the operating system. TRUNCATEONLY: Causes any unused space in the data files to be released to the operating system and shrinks the file to the last allocated extent, reducing the file size without moving any data. No attempt is made to relocate rows to unallocated pages. target percent is ignored when TRUNCATEONLY is used. For e.g., DBCC SHRINKDATABASE (NameOfDB, 5,TRUNCATEONLY) Useful Link: http://www.sourcecode.co.nz/shrinkdbs/index.htm |
| Linking Database |
|
Linking database provides you a way to connect to a database of different source within your own data source environment. For e.g., the data operations can be done between an Access database (*.MDB file) and MS SQL Server 7.0 database and vice-versa. Since MSDE database has 100% compatibility with SQL server 7.0, it is also capable of generating linked servers. 1. The MDB file (or for that matter any database file) which you want to add into MSDE database, that file must be residing on the same MSDE server where you want to add it as a linked server. 2. If step 1 is not followed, the OLE DB provider gives error that ‘The specified database file could not be found. 1. sp_addlinkedserver: Before you communicate to a database on different data source, you need to create its linked server. The sp_addlinkedserver has following parameter syntax: sp_addlinkedserver [ @server = ] 'server' [ , [ @srvproduct = ] 'product_name' ] [ , [ @provider = ] 'provider_name' ] [ , [ @datasrc = ] 'data_source' ] [ , [ @location = ] 'location' ] [ , [ @provstr = ] 'provider_string' ] [ , [ @catalog = ] 'catalog' ] Linked server for Access DB: Assume that MSDE server is running on machine ‘ABC’, then the syntax would be, EXEC sp_addlinkedserver @server='myacc', @srvproduct='', @provider='Microsoft.Jet.OLEDB.4.0', @datasrc='F:\Priya\mydb.mdb', @provstr=NULL, @catalog=NULL @server is the name of the linked database, @datasrc is the location of the MDB file (Make sure that the MDB file resides on the same server as ‘ABC’ in this case), @Provider is the name of the OLE DB data source etc. Linked server for SQL Server 7 DB: EXEC sp_addlinkedserver @server='MySQL’, @srvproduct='', @provider='SQLOLEDB', @datasrc='comp5', @catalog='TP' go For more information on its argument listing, please visit the following link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sp_adda_8gqa.asp The above link also tells you how to connect to other OLE DB data sources. Run this SQL statement and then go to Step 2. If the above named linked server already exists, then one can directly go to step 3. 2. sp_addlinkedsrvlogin: This stored procedure is used to create login mappings from local logins to MS Access (or any other database) logins. The sp_addlinkedsrvlogin has the following syntax: sp_addlinkedsrvlogin [ @rmtsrvname = ] 'rmtsrvname' [ , [ @useself = ] 'useself' ] [ , [ @locallogin = ] 'locallogin' ] [ , [ @rmtuser = ] 'rmtuser' ] [ , [ @rmtpassword = ] 'rmtpassword' ] For more information on its argument meaning, please visit the following link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sp_adda_6e26.asp For e.g., In case of MS ACCESS DB, sp_addlinkedsrvlogin 'myacc', 'FALSE', NULL, 'Admin', Null. In case of SQL server, sp_addlinkedsrvlogin 'mysql', 'FALSE', NULL, 'sa', ‘’. 3. Executing the query: Once the linked servers are created, the query can be created in 3 using following: a. OPENQUERY: This executes the specific query using linked server. The OPENQUERY function can be referenced in the FROM clause of a query as though it is a table name. The OPENQUERY function can also be referenced as the target table of an INSERT, UPDATE, or DELETE statement, subject to the capabilities of the OLE DB provider. Although the query may return multiple result sets, OPENQUERY returns only the first one. The syntax of the OPENQUERY is as follows: OPENQUERY (linked_server name, 'query') For e.g., To retrieve data from MS ACCESS database will be, Select * from OPENQUERY(myacc, 'Select * from myTab') Where ‘myacc’ is the name of the linked server and we are retrieving records from ‘mytab’ table. For more information on OpenQuery, please visit the following link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_oa-oz_5xix.asp b. OPENROWSET: OPENROWSET is another method by which one can retrieve data from another data source. It does not require any linked server as such. The syntax is as follows: OPENROWSET ( 'provider_name' , { 'datasource' ; 'user_id' ; 'password' | 'provider_string' } , { [ catalog. ] [ schema. ] object | 'query' } ) For e.g., SELECT * From OPENROWSET ('Microsoft.Jet.OLEDB.4.0','F:\Priya\mydb.mdb';'admin';'', MYTAB) For more information on Openrowset, please visit following link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_oa-oz_78z8.asp c. Using 4 part name syntax: This requires the linked server. The syntax is as follows, Select * from (linked server name)…(table name) For e.g., Select * from MYACC...MYTAB. This query works for only SQL server 7.0 version. The created linked server can be deleted through ‘Enterprise Manager’ by performing the step-by-step procedure as given below: · Expand a server group, and then expand a server. · Expand Security, and then expand Linked Servers. · Right-click the linked server to delete, and then click Delete. · Confirm the deletion. For more information, please visit following link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/howtosql/ht_servpem_46nt.asp Delete using stored procedure: Sp_dropserver will drop the specified linked server. The syntax is as following: sp_dropserver [ @server = ] 'server' [ , [ @droplogins = ] { 'droplogins' | NULL} ] For eg, exec sp_dropserver 'myacc' For more information, please visit the following link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/tsqlref/ts_sp_drop_9c1e.asp Other useful links on linked servers: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q246255 http://support.microsoft.com/default.aspx?scid=kb;EN-US;q200797 http://support.microsoft.com/default.aspx?scid=kb;EN-US;q218592 |
| Download Example in VB |
|
Download VB Code |
| Migration of SQL Server database to MSDE database |
|
1. MSDE is fully compatible with SQL server 7.0, i.e., all the tables, stored procedures, views used within SQL server can be used for MSDE without any change in the code written to access them. |
| References on MSDE |
|
Complete guide on MSDE |
Home | More About Me 