DataStructure file and file with inserts - sql

I have a .sql file with the datastructure and one with the inserts.
How can I import the to Microsoft SQL Server 2012 Management Studio? If anyone interest here is the file for inserts and for datastructure.
If you can't download the file you can find the content of datastructure here and for inserts here

If the files had contained sql code that you could run in SMSS you would use file->open->file (or ctrl+o) to open the file.
Your files however are MySQL dumps and contain code that MS SQL won't understand that you need to fix. Using the reference documentation it should be easy to alter the structure-file so that it works. In the insert-file you probably only need to remove the backticks.

Related

How to convert .sql file into .mdf file?

I have a .sql file. How can I convert this .sql file to a .mdf SQL Server database file?
I know that .sql file is nothing but a script file if I open the .sql file in notepad it will show me the db code I can simply copy those code and paste into SQL Server Management Studio.
Is there any other way to convert .sql to .mdf file?
Unless your SQL file contains the script to create a database, your question wouldn't make any sense. If it does contain such script you need an environment to execute it. There are many tools that will allow you to do that. For example, many IDE tools that integrate with SQL Server have such capability.
So to answer your question: it is impossible to convert SQL file to MDF. You, however, can sometimes use an SQL file to build MDF.

Import updating CSV into SQL Server

I'm looking for a simple solution (beginner to SQL) to allow the import of data from my .csv file to my SQL DB.
I have a third party program that is updating my .csv file every 30 seconds and I want to put that updating information into my SQL DB. I tried the importing & exporting wizard but it didn't work due to the .csv file being utilized by the other third party program.
Getting the information into the SQL DB doesn't need to be in real time it could just retrieve all the information when opening a saved sql query file.
Thank you!
OPENROWSET is the simplest one if you get that working in your env for CSV file. i have seen lot of issues with what OS, and what version of MS office installed with 32bit or 64 bit.
but bit more work and you will be all set with creating a small SSIS package to import that CSV in to table. execute that SSIS using SQL JOB at desired interval. later if you needed more complex insert/update you can always modify the package.
This is the case of producer consumer problem where one process is writing data and another one is reading it.
Whatever you do you need to setup some kind of lock on this file that process can check if file is available for reading/writing. If import/export wizard had issues with concurrency then probably other processes will also.
Another option is to always create new file to write into and have reader process to always read from the newest one and delete it after processing.
One more thing you’ll have to take care of is reading from same file multiple times. You need some way to mark the records that have already been read so these are not inserted twice.
All of the above is needed if this needs to be a fully automated and unattended process.
If not you can just manually create a copy of CSV file and then use import/export wizard to import the data.
Here is another resource you can check out for importing CSV into SQL Server
http://blog.sqlauthority.com/2008/02/06/sql-server-import-csv-file-into-sql-server-using-bulk-insert-load-comma-delimited-file-into-sql-server/

How to import a SQL file into SQL Server 2008 using Visual Studio 2010?

What I tried so far is to go to server explorer:
connect to a database
choose server name
and tried to attach a database file but it asks for an .mdf file and I don't know what is this and how to create it. My database is a .sql file
A .sql file, is a file that contains statements that can be executed. They can contain statements that create database and tables (and other stuff) or that manipulate the data in an existing database (like inserting records).
If you want to execute the .sql file, you can open it in Visual Studio and then run it. It will ask you for a connection to a Sql Server instance and then the statements will be executed.
Here is the MSDN documentation that explains this.

Import .sql file in Access

I need to import to Access a .sql database backup file created with MySql .
Is there a way to perform this operation?
You can't restore a MySQL backup into any other database system.
If you want to import the MySQL data into Access, you could export it all into CSV files and import those to Access. You will still need to recreate relationships, defaults, indexes (?) and other data.
You can import SQL Server data into a new Access table. In general, importing is a way to convert data from a different format and copy it into Access. The source table or file is not altered in this process. You can import directly from a SQL Server database using an ODBC connection, a text file exported from SQL Server, or an XML file exported from SQL Server.
To make frequent import operations more convenient, you can automate them by creating a macro or creating a Microsoft Visual Basic for Applications (VBA) procedure. This is useful, for example, when you import data on a regular schedule or you have unusual or complex requirements for importing data.
if you use SQL Server Management studio then you can open the .SQL files and it will give you help in figuring out what syntax works in SQL -- and which doesn't.
For example, if you have a table name that is mis-spelled, SQL Server Management Studio will give you red squigglies under that table name.
I don't see that functionality in Access, and I don't think that it's coming any time soon. Access (Jet) hasn't gotten any new features in almost fifteen years.

How to edit a Word Document (.docx) stored in a SQL Server Table?

How to edit a Word Document (.docx) stored in a SQL Server Table?
Here is the tentative work flow:
Read BLOB from SQL Table through Ideablade
Write BLOB to disk as .docx
Open .docx using Word
User makes changes
Save .docx using Word
Read .docx into BLOB
Write BLOB back to SQL Table through Ideablade
All sample code is welcomed?
I am sure there are a lot of people doing this already.
Any other ideas on how to simplify this process?
I am using VB.NET, .NET 3.5 SP1, WinForm and SQL Server 2008.
Well, as to the how, here is how to read a blob and write a blob to SQL. Although frankly, unless you have very good reasons such as an existing backup system, you would probably be best served storing the file to the file system and the path and metadata in the database. Either way, abstract it in your BLL, so you can change your mind down the road.
Retrieving and updating the BLOB from the db shouldn't be a problem, you'll find lots of sample code to do that on the net.
A simple approach to your problem would be to create a "temp" or "working" directory somewhere and monitor it with System.IO.FileSystemWatcher (sample code). When the user wants to edit a file, fetch it from the db and store it the directory. Whenever the user saves the file, you'll get a notification from your FileSystemWatcher, so you can save it to the database. Don't forget to empty the directory from time to time.
The method I've seen for this that I think works best is to build this as an add-on for MS Word itself. Examples include the Save to Sharepoint, Save to Moodle, and other similar add-ins.