|
Recent Articles |
Developing Countries Breeding Grounds... Red Herring's Falguni Bhuta predicts "More (Open Source) momentum in developing countries": "Open-source software's transparent nature and low-cost will make it more popular among developing countries such...
SQL Server Triggers Triggers are stored procedures which are fired when data is modified in an underlying table. They can evaluate data being added to a table for validation purposes, or can make changes in that or other fields depending...
SQL Server 2000 Data Types SQL Server requires that each variable and column in a table should be defined with respect to the type of data it will store. From a bit to a huge image and binary storage types, the allocation is supposed to help...
Using DataTables More For Improving Performance There are some features in the System.Data.DataTable class that a lot of developers don't utilize. I base that statement on different code samples I've seen on blogs and article bases during the last couple of years.
Open Source SQL Full Text Search Engine - Sphinx CLR or TSQL? That is the question. More are more developers are struggling to find the right answer, but the answer really depends on the developer's individual needs. For classic SQL tasks, the good old TSQL...
CLR Vs T-SQL And Stored Procedures In SQL Server CLR or TSQL? That is the question. More are more developers are struggling to find the right answer, but the answer really depends n the developer's individual needs. For classic SQL tasks, the good old TSQL...
|
|
|
01.23.07
Convert A MySQL Injection Script For Use In Microsoft SQL Server By Lucas Green
MySQL Server is the most widely used database management system in the world, primarily because it is open source and free.
Hence, most databases you may get from outside sources will probably be in the form of a MySQL injection script. This is fine if you use MySQL for your own website databases, but if you use Microsoft SQL Server the script will require a little editing before it will work.
The first thing you'll need to do is remove any comment lines from the script. MySQL comment lines begin with a pound character ("#") and MSSQL comment lines begin with a double dash ("--"), which makes them completely incompatible and will product a syntax error if you try to import a MySQL injection as-is into MSSQL Server. So to get started, open up Query Analyzer if you haven't already (the easiest way to run scripts in MSSQL Server), load up the injection script you are working with, and remove any comment lines (look for the pound symbol). It is easier just to remove them than it is to try and convert them to propery MSSQL syntax, and they are just comment lines anyway so it won't affect anything.
The bulk of your script will most likely be a series of INSERT statements, and these aren't very different in MSSQL as compared to MySQL. However, your script may also include at the beginning a small section that creates the database table where the data will be inserted, and this CREATE TABLE statement is likely to be VERY different in MSSQL, depending on how complicated it is (there could be primary and secondary keys, constraints, even triggers -- the more of these the more the syntax changes from MySQL to MSSQL). Since this is likely to give you the most trouble, it is recommended that you create the database tables manually in Enterprise Manager rather than trying to convert the syntax of the script snippet. Looking at the code, you should be able to easily identify the fields and their types (such as int, varchar, text, etc). Once you have the database table created in Enterprise Manager, delete the snippet of code from the injection script that deals with the creation of the table.
Now all that remains is to convert the INSERT statements to the proper syntax for MSSQL Server. There are a few different steps to accomplish this, but none of them are very complicated. The first difference in syntax between MySQL and MSSQL is that in MySQL, all statements must end with a semicolon (";"). In MSSQL, this is a syntax error. The easiest way to remove these semicolons is to do a search and replace, and since the INSERT statements should be passing a series of values for each record of data, each line of the MySQL script will most likely end with a paranthesis and semicolon (");"). So, do a search and replace and replace all instances of ");" with just the parenthesis ")".
Continue reading this article.
About the Author: This article was written by Lucas Green, a professional private web developer who lives off his internet income. To visit his website and learn more about how he is creating multiple streams of passive income using the internet, please visit www.lucasgreen.com !
|