How to view and change data of a .mdf file using MS Access? - sql

Background: I have an .mdf database containing some numeric values that I need to change (specifically, scale and offset values for sensors). The database was created by a Visual Basic program that controls some lab equipment and stores pertinent data in the .mdf file. Please excuse my rudimentary knowledge of the topic; I'm a complete novice when it comes to SQL Server and VB.
After searching through many posts, I understand that to open the .mdf file, you must "attach" it in Microsoft Server Management Studio (I'm using that with SQL Server 2005), which I have successfully done.
Problem: It seems that this only allows me to view and modify the structure of the database, ie. tables, columns, data types etc., rather than the values of the database itself.
Is there a way to do this manually, like how you can edit the field data of .mdb files in MS Access? Again, sorry for my limited knowledge on the topic. I'll gladly provide extra details where needed.

You mention you want to use access. That can be done. Your database is up and running after attaching it.
In Access you can simply create an ODBC connection in access and use Access to edit/modify your data as much as you want. you can also create queries.
It is in the menu item "external data" [I'm guessing because I use a dutch version]. You select to create a "linked table", choose your server and you are done.

Right-click on the table you want to modify in SSMS and select "Edit Top 200 Rows".
If you have more than 200 rows to edit, you can connect to the SQL Server database with either Access or Excel.
Here are the instructions for Access:
http://office.microsoft.com/en-us/access-help/connect-an-access-project-to-a-microsoft-sql-server-database-adp-HP005274586.aspx

Related

How do I add records from an Access database into an existing SQL Server database?

I have an existing Access database that has out grown it's usefulness. I have written a Visual Basic program that uses a SQL Server database and have been re-entering the data from the Access file into SQL Server individually.
I still have 300+ records to move and would like to find a way to do all this using either a data snippet in Visual Basic, or using SQL Server Express. I'm smart enough to set up and use Access, and smart enough to create a program and database in Visual Basic and SQL Server but for some reason I not smart enough to move the records between the 2 databases.
When I originally created the .mdf file I attempted to move the records at that time but everything I tried didn't work so I figured I'd get it later, but now I have 300+ records in the .mdf file and need to get the others moved over. Anybody have any ideas?
Easiest thing to do is create your database, then in SSMS's Object Explorer, right click on the database, Tasks -> Import Data ... and go through the Import/Export wizard, selecting MS Access as your source.

redirecting existing Access forms to SQL Server

In our organisation, we have Sales Database in Access. The Access database has few forms and few reports. Over time, the Access database has grown. Retrieving records via forms has become slow and cumbersome.
We have decided to divide the migration two phase – short term and long term. In short term, we want to migrate the Access database to the SQL Server and leave the forms and reports in Access as it is. I have to link the forms and reports to the SQL Server tables.
I have successfully migrated the Access database to SQL SERVER using migration assistant tool. I am stuck at changing the forms to talk to the SQL Server.
My question is –
Is it possible to change the existing access form to talk to SQL SERVER?
If the above answer is wrong, what are other method I can use to achieve the same objective?
Your help is much appreciated.
I belive you can do it by creating "linked tables" with the same name as the original tables.
I've done it using ODBC in the "External Data" on the menu bar, chose "ODBC Database", and then "Link to DataSource, and create linked tables".
When the wizard is finished "it's pretty much forward", just change the table names to the original table names, and the forms should work as "nothing had changed".

Accessing Content from MDF after attached to SQL

I am using WSS 3.0 and trying to restore a mdf. I attached the database in SQL Management Studio, created a new web application, and associated the database to it. When I go into Central Administration-> Application Management -> Content Databases I see the WSS_Content and it says Sites: 2. One of the sites looks more similar to the other. I was able to log into the Sharepoint web app that has the db attached to it, and while it gives me the basic structure of the backed up site, the content of lists is blank, that was the data I was really after (Announcements, tasks, etc exist as lists but are empty). How do I get access to this?
Kindly remove your old database and make newly added database as a default/only database for your webapplication
I'd link to the the data from SQL Server into an Access database.. and then use MS Access to write these values back into sharepoint.
I've written a LOT of data to sharepoint using MS Access.. and I love the functionality.
the data is in SQL server.. but it's got different guids, or it's not wired up from what I'd assume.
You have the data posted to the SQL Server instance.. I'd just link to it in MS Access, write a couple of queries.. recreate a couple of lists.. and then push it from queries based on Access linked tables (to sql server).. and then jam it into Access linked tables (to sharepoint).
Open Access. right-click link basically. times two. and write a couple of queries.
If it was me, and it was just a couple of lists, I'd do this in a couple of minutes I swear.

How to get script of SQL Server data? [duplicate]

This question already has answers here:
What is the best way to auto-generate INSERT statements for a SQL Server table?
(24 answers)
Closed 6 years ago.
I'm looking for a way to do something analogous to the MySQL dump from SQL Server. I need to be able to pick the tables and export the schema and the data (or I can export the schema via SQL Server Management Studio and export the data separately somehow).
I need this data to be able to turn around and go back into SQL Server so it needs to maintain GUIDs/uniqueidentifiers and other column types.
Does anyone know of a good tool for this?
From the SQL Server Management Studio you can right click on your database and select:
Tasks -> Generate Scripts
Then simply proceed through the wizard. Make sure to set 'Script Data' to TRUE when prompted to choose the script options.
SQL Server 2008 R2
Further reading:
Robert Burke: SQL Server 2005 - Scripting your Database
SQL Server Management Studio
This is your best tool for performing this task. You can generate a script that will build whichever tables you wish from a database as well as insert the data in those tables (as far as I know you have to export all of the data in the selected tables however).
To do this follow these steps:
Right-click on your database and select Tasks > Generate Scripts
In the Generate and Publish Scripts wizard, select the "Select specific database objects" option
Expand the "Tables" tree and select all of the tables you wish to export the scheme and data for, then click Next
In the next screen choose how you wish to save the script (the Output Type must remain set as "Save scripts to a specific location"), then click the Advanced button in the top right corner
In the newly opened window, under the General section is a setting called "Types of data to script", set this to "Scheme and data" and click OK
Click Next, review the export summary and click Next again. This will generate the script to your selected destination.
To restore your database, simply create a new database and change the first line of your generated script to USE [Your.New.Database.Name], then execute. Your new database will now have all of the tables and data you selected from the original database.
I had a hell of a time finding this option in SQL Management Studio 2012, but I finally found it. The option is hiding in the Advanced button in the screen below.
I always assumed this contained just assumed advanced options for File generation, since that's what it's next to, but it turns out someone at MS is just really bad at UI design in this case. HTH somebody who comes to this thread like I did.
If you want to script all table rows then
Go with Generate Scripts as described by Daniel Vassallo. You can’t go wrong here
Else
Use third party tools such as ApexSQL Script or SSMS Toolpack for more advanced scripting that includes some preprocessing, selective scripting and more.
Check out SSMS Tool Pack. It works in Management Studio 2005 and 2008. There is an option to generate insert statements which I've found helpful moving small amounts of data from one system to another.
With this option you will have to script out the DDL separately.
SqlPubWiz.exe (for me, it's in C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Publishing\1.2>)
Run it with no arguments for a wizard. Give it arguments to run on commandline.
SqlPubWiz.exe script -C "<ConnectionString>" <OutputFile>
BCP can dump your data to a file and in SQL Server Management Studio, right click on the table, and select "script table as" then "create to", then "file..." and it will produce a complete table script.
BCP info
https://web.archive.org/web/1/http://blogs.techrepublic%2ecom%2ecom/datacenter/?p=319
http://msdn.microsoft.com/en-us/library/aa174646%28SQL.80%29.aspx
I know this has been answered already, but I am here to offer a word of warning.
We recently received a database from a client that has a cyclical foreign key reference. The SQL Server script generator refuses to generate the data for databases with cyclical references.

Automatically Generate SQL from existing MS Access table

I've just designed a large database by playing around in MS Access. Now that I'm happy with the design, I need to be able to generate this same database (tables, relationships, etc.) from code.
Rather than hand-writing the SQL CREATE statements (which will be long, tedious, and error-prone process), I was wondering whether there was a shortcut. I seem to recall from my limited exposure to MySql that I was able to export an entire database as an SQL statement that can then be run in order to regenerate that database.
Do you know of a way to do this in MS Access, either through the GUI, or programmatically?
I just found and tried out this tool: jet-tool. It seems to work well for Access 2010.
For free for 30 days (then $30) you can give DBWScript a go, looks like its what you are asking for, although not in native Access GUI or programmatically
The quick and dirty, easy, perfectly legitimate way to do this is just copy the .mdb file. Empty out the data if you need to - usually there are static tables that are handy to leave populated, however.
I use a free utility called MDB Viewer Plus (http://www.alexnolan.net/software/mdb_viewer_plus.htm).
Launch it, open your db, then select your table.
On top menu, select "Table > Generate SQL - CREATE".
I don't know what tools you have on your development machine, so this may or may not be helpful.
You can easily transfer your Access database to Microsoft SQL Server using the Upsizing Wizard.
The express edition of SQL Server is available for free > here.
You will also want to get the free Management Studio Express.
Using these free graphical-based tools you can easily generate the SQL statements to re-create the database. You will have the Create statements you are looking for and they will be placed in a text file.
The Bullzip is very good to this. Very simple. See bullzip Access to MySQL for example
It is possible export any tables to SQL or migrate automatically.
Access to MySQL is a small program that will convert Microsoft Access Databases to MySQL.
Wizard interface.
Transfer data directly from one server to another.
Create a dump file.
Select tables to transfer.
Select fields to transfer.
Transfer password protected databases.
Supports both shared security and user-level security.
Optional transfer of indexes.
Optional transfer of records.
Optional transfer of default values in field definitions.
Identifies and transfers auto number field types.
Command line interface.
Easy install, uninstall and upgrade.
The thing that you're mentioning in MySQL is sql dumping. Very useful feature. If you want to migrate the database to mysql, here's a helpful article.
http://www.kitebird.com/articles/access-migrate.html#TOC_4
I have been using for years a tool called database.net from https://fishcodelib.com/Database.htm
I generally use it on client's site as a portable version of SSMS (drop and run), but it can handle a multitude of RDBMSes, including Access.
Connect to your mdb/accdb, right click any table, choose SCRIPT AS, Create, and you're done.
If you right click Tables header, you can select multiple tables to generate, but I think it's a feature of the paid version.
I have no acquaintance with them, just a happy client.
I found an easy way to go:
Export-> ODBC Database
and then retrieve the SQL form there (e.g via pgadmin on postgres)
Compare'Em
http://home.gci.net/~mike-noel/CompareEM-LITE/CompareEM.htm
The free version creates VBA while the $10 pro version gives you DDL statements.