How to import .sql file into MS Access - sql-server

This is an assignment. I have to import a .sql file into MS Access. The file preferably will be NorthWind Database (.sql file). I have downloaded one from:
https://northwinddatabase.codeplex.com/releases/view/71634
and it contains a .sql file.
What to do next?
(Please note that importing/connecting MS Access from/to MS SQL Server through ODBC is irrelevant to this problem. The problem is to import a generic .sql file)

That's plain impossible without a major rewrite, and I seriously doubt if that is the assignment given to you.
The SQL for download is in T-SQL for building the complete database in SQL Server.
The Nortwind database is for download in an Access version if that is what you need.

You are going to have to rewrite it, but you should be able to open it with any text editor like notepad. Then you can copy and paste it into the sql view in the query designer.

Related

Import DB2 files to SQL Server

Given the DAT file and the DDL file for each table in a DB2 database, can I import this data to SQL Server? I have no access to the original server or any copy of a DB2 server so connecting to a live instance isn't an option.
Can I do this without a live instance of DB2 or should I go back to the client and ask for CSV files? Is there a procedure or tool that makes this process smoother? I've tried to find a file-based connection string to use to connect to a set of DB2 files with no luck. I've also tried SwissSQLDB2ToSQLServer and SqlLinesData to see if they have a file-based option built in.
OK, given the comment above, you can't import DB2's container files (DAT, LRG, or anything else) directly. You need a CSV or equivalent. Yes, one way to get this is run the EXPORT utility on a live DB2 database. HTH!

How to schedule data insertion from dbf to SQL Server on 64-bit Windows Server 2012

I am working on a Windows Server 2012 64-bit. I want to be able to import data from a .dbf file into a SQL Server table. I used the import wizard and it worked correctly. However, I have SQL Server Express and can't schedule this insertion.
Is there another way to schedule the insertion of the .dbf data to the SQL Server tables, without the use of the SSIS package loader?
Update
I ended up using Python and writing a script to import from XML. However, I believe the answer by #Oleg was the most accurate, given the circumstances.
Thank you all!
You can also use DBF Commander Pro for this task:
Create command line for your insertion - choose 'File -> Export to DBMS'. Specify transfer options in the window appears, then copy the command line from the bottom of the window:
Create text .BAT file and insert the copied command line, e.g.:
"c:\Program Files\DBFCommander\DBFCommander.exe" -edb "D:\Data\customer.dbf" customer_table "Provider=SQLOLEDB.1;User ID=user1;Initial Catalog=test_db;Data Source=test_server"
Make a schedule using Windows Scheduler that will execute this .BAT file.
Additional info that may be useful for you:
Using DBF in batch mode
Export DBF file to SQL database
I suggest you the next approach:
Create C# script which will use the OleDbConnection (to fetch) and SqlConnection (to upload) objects to import data from the .DBF file to SQL Server database table.
By using LinqPad, LinqPad command-line utility (lprun.exe) and windows Scheduled Task service automate the execution of the mentioned script file
Useful links:
How to get data from DBF file using C#
How to load data into datadase using C#
About LINQPad command-line utility
Another way is create a SQL linked server an ODBC that is pointing at the DBF. Use Windows scheduler to call SQLCMD.EXE to run some SQL to copy the data in.

How to dump SQL Server data into csv

I'm converting web application written in ASP into PHP that will be using MySQL. I have a SQL Server database with two files (.MDF and .LDF) I want to convert into CSV file but I am having trouble finding the right tool to do the job. I found that some people are suggesting SQL Server Express. I tried it but couldn't figure out how to load database from file and use it. I also tried to use opendbcopy but when trying to open a file it doesn't show it in the file pane.
If you install SQL Server Express, you can load the image file using the Attach Database functionality in the SQL Server Management Studio (the management UI).
Then you can view and work with the database directly from Management Studio, where you can export the file to CSV by right-clicking the database name and selecting Tasks->Export Data.
There's an online service called RebaseData that can do the job. You just need to upload your .MDF file and it gets converted to a .ZIP archive. The .ZIP archive will contain several .CSV files, one for each table of the database.
Link to the converter
Disclaimer: I'm working for that service.
connect database to visual studio and write query to display all data from the table you want and then right click and select all and again right click and save it .
Its done !

Data in local .mdf file didn't changed, but no error

I use a .mdf file as my database. I also used Linq-to-SQL connection.
At first, my application can add and display the data in the .mdf file correctly. But when I try to see the data by clicking the .mdf file directly and from the table, the database is empty.
I've set the .mdf file and the .dbml file Copy if newer, but still nothing.
Please help me and thank you for your help.
I bet your connection string contains
AttachDbFileName=somefilename.mdf
The whole User Instance and AttachDbFileName= approach is flawed - at best! Visual Studio will be copying around the .mdf file and most likely, your INSERT works just fine - but you're just looking at the wrong .mdf file in the end!
If you want to stick with this approach, then try putting a breakpoint on the myConnection.Close() call - and then inspect the .mdf file with SQL Server Mgmt Studio Express - I'm almost certain your data is there.
The real solution in my opinion would be to
install SQL Server Express (and you've already done that anyway)
install SQL Server Management Studio Express
create your database in SSMS Express, give it a logical name (e.g. YourDatabase)
connect to it using its logical database name (given when you create it on the server) - and don't mess around with physical database files and user instances. In that case, your connection string would be something like:
Data Source=.\\SQLEXPRESS;Database=YourDatabase;Integrated Security=True
and everything else is exactly the same as before...

Import DAT Files into Sql Server 2008

I Recently received a DAT file containing a SQL database, i would like to restore the database into my server for testing purposes, i tried to add it with the Task->Restore->Database but it didn't come up as a valid file when browsing for the DAT file, then if i select it with the "all files" option it will tell me that the file format is invalid. Does anyone know how to load those kinds of files into SQL Server 2008?
Thanks
Actually this was the issue. the DAT was a normal .Bak, but the file became corrupted while uploading\downloading from an FTP server... Weird
Regards!
Just had this exact error and found a much simpler fix.
Change the extension to .txt from .dat and then import the file via the import wizard built into SQL Server or via SSIS. To my understanding the solution in your link should only be necessary for .bak files.

Resources