tags:

views:

105

answers:

3

i have about 8mb of sql code i need to run. it looks like this:

/*
MySQL Data Transfer
Source Host: 10.0.0.5
Source Database: jnetdata
Target Host: 10.0.0.5
Target Database: jnetdata
Date: 5/26/2009 12:27:33 PM
*/

SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for chavrusas
-- ----------------------------
CREATE TABLE `chavrusas` (
  `id` int(11) NOT NULL auto_increment,
  `date_created` datetime default NULL,
  `luser_id` int(11) default NULL,
  `ruser_id` int(11) default NULL,
  `luser_type` varchar(50) default NULL,
  `ruser_type` varchar(50) default NULL,
  `SessionDay` varchar(250) default NULL,
  `SessionTime` datetime default NULL,
  `WeeklyReminder` tinyint(1) NOT NULL default '0',
  `reminder_phone` tinyint(1) NOT NULL default '0',
  `calling_card` varchar(50) default NULL,
  `active` tinyint(1) NOT NULL default '0',
  `notes` mediumtext,
  `ended` tinyint(1) NOT NULL default '0',
  `end_date` datetime default NULL,
  `initiated_by_student` tinyint(1) NOT NULL default '0',
  `initiated_by_volunteer` tinyint(1) NOT NULL default '0',
  `student_general_reason` varchar(50) default NULL,
  `volunteer_general_reason` varchar(50) default NULL,
  `student_reason` varchar(250) default NULL,
  `volunteer_reason` varchar(250) default NULL,
  `student_nli` tinyint(1) NOT NULL default '0',
  `volunteer_nli` tinyint(1) NOT NULL default '0',
  `jnet_initiated` tinyint(1) default '0',
  `belongs_to` varchar(50) default NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=5913 DEFAULT CHARSET=latin1;

-- ----------------------------
-- Table structure for tbluseravailability
-- ----------------------------
CREATE TABLE `tbluseravailability` (
  `availability_id` int(11) NOT NULL auto_increment,
  `user_id` int(11) NOT NULL,
  `weekday_id` int(11) NOT NULL,
  `timeslot_id` int(11) NOT NULL,
  PRIMARY KEY  (`availability_id`)
) ENGINE=MyISAM AUTO_INCREMENT=10865 DEFAULT CHARSET=latin1;

-- ----------------------------
-- Table structure for tblusers
-- ----------------------------
CREATE TABLE `tblusers` (
  `id` int(11) NOT NULL auto_increment,
  `

etc

how do i run it on microsoft sql 2008?

+3  A: 

You don't, you'd have to convert the code to use SQL Server's T-SQL syntax. You could use a conversion tool though, like this one.

Mr. Smith
im getting an error with this conversion tool
I__
+1 because you referenced a useful tool, but it might be worthwhile to attempt a manual conversion at first just to see what the differences are. Then use the tool so you don't have to convert 8MB worth of SQL code.
Mayo
It's not just a tool, there's actual code that can be used on that site, although I'm have no idea if you use that language.
Mr. Smith
@avrohom, the error you're getting is because there's a type inside your structure (in this case mediumtext) in the first example that this tool does not cater for. You could however tweak the code and add your own conversion. No one said it was going to be 100% painless :)
Mr. Smith
@Boekwurm, mediumtext is a valid data type in mysql that a conversion tool should be able to handle.
longneck
A: 

At a glance, the code snippet you provided looks acceptable for SQL Server. I would suggest using one of the many tools available for executing SQL against an existing SQL Server instance (SQL Server Management Studio, Query Analyzer, etc.). Paste the code into a new query window (or open up the associated file with the query) and parse it to see if you uncover any errors. Once you tweak the code to work with SQL Server 2008 (assuming that's necessary), you should just be able to execute it to create the tables and such.

EDIT: I tested your code against SQL Server 2005 and there were some problems that would be annoying like replacing ` with ', fixing table/column references surrounded by apostrophes, etc.. Automated tool would be your best approach given the prevelance of errors.

Mayo
+2  A: 
Rodrigo
Actually, I think that last one should be replaced with " ON [PRIMARY]"
BoltBait
the default filegroup is primary, but yes, it can be replaced with ON [PRIMARY]
Rodrigo