By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,485 Members | 1,031 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,485 IT Pros & Developers. It's quick & easy.

import .sql script into sql server

P: n/a
jet
Hi,

Maybe this is an easy task, but I'm having a really hard time figuring
out how to do this. I'm a complete newbie to SQL Server.

I have a database dump file from MySQL that's in .sql format. I'm
trying to figure out how to import that into SQL Server 2000 so that
I'll be able to manipulate it in a gui format, rather than command
line. I can't find any import that takes a .sql file. I've been
trying to load it into the query analyzer and am also having problems
with that. Initially I had problems because there were question marks
within some of my data. I've removed those but when I run the query I
still get a bunch of syntax errors. Looking at the errors, the syntax
seems correct.

Does anyone know of a way to import a .sql script without having to
import it into the query analyzer? It seems like it should be a
no-brainer..... but perhaps my brain is lacking... I don't know!

Thanks for the help!

--jet
the following are the errors that I get and the associated code:
-----------------------------------------------------------------------------
Server: Msg 170, Level 15, State 1, Line 17
Line 17: Incorrect syntax near ','.

CODE: INSERT INTO answers VALUES
('travelMethodRadio','j**********@montana.com','te lemark'),

The second line is line 17, and it is followed by more insert values.
------------------------------------------------------------------------------
Server: Msg 170, Level 15, State 1, Line 7093
Line 7093: Incorrect syntax near 'a'.

CODE: ('groupSlopeTravelText','k*********@jhmg.com','Thi s is
completely dependent on conditions and if it is a heavily used area or
a fairly pristine area'),

This is just one in a long list of insert values... no idea why there
is a problem with this particular one.
-------------------------------------------------------------------------------
Jul 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"jet" <je*********@yahoo.com> wrote:
Hi,

Maybe this is an easy task, but I'm having a really hard time figuring
out how to do this. I'm a complete newbie to SQL Server.

I have a database dump file from MySQL that's in .sql format. I'm
trying to figure out how to import that into SQL Server 2000 so that
I'll be able to manipulate it in a gui format, rather than command
line. I can't find any import that takes a .sql file. I've been
trying to load it into the query analyzer and am also having problems
with that. Initially I had problems because there were question marks
within some of my data. I've removed those but when I run the query I
still get a bunch of syntax errors. Looking at the errors, the syntax
seems correct.

Does anyone know of a way to import a .sql script without having to
import it into the query analyzer? It seems like it should be a
no-brainer..... but perhaps my brain is lacking... I don't know!

Thanks for the help!

--jet
the following are the errors that I get and the associated code:
-------------------------------------------------------------------------- --- Server: Msg 170, Level 15, State 1, Line 17
Line 17: Incorrect syntax near ','.

CODE: INSERT INTO answers VALUES
('travelMethodRadio','j**********@montana.com','te lemark'),

The second line is line 17, and it is followed by more insert values.
-------------------------------------------------------------------------- ---- Server: Msg 170, Level 15, State 1, Line 7093
Line 7093: Incorrect syntax near 'a'.

CODE: ('groupSlopeTravelText','k*********@jhmg.com','Thi s is
completely dependent on conditions and if it is a heavily used area or
a fairly pristine area'),

This is just one in a long list of insert values... no idea why there
is a problem with this particular one.
--------------------------------------------------------------------------

-----

jet,

Before answering your question... if you use the ODBC driver for MySQL, you
can use SQL Server DTS to get table structure and data to/from MySQL. IMHO,
it's much easier that way. However, to answer your question...

The problem you're having would be the same going from SQL Server back to
MySQL: they both use extensions to SQL. Query Analyzer is definitely the
tool to use if you want to run a MySQL .sql file vs your SQL Server.
However, some things to keep in mind..

- Neither SQL Server nor Query Analyzer recognize "#" as a comment
character: use "--" instead.

- MySQL escapes single quotes in a string literal with a backslash (\'): SQL
Server escapes them with an extra single quote ('').

- MySQL allows you to "chain" records for an insert (this is the error
you're getting above). When I generate a SQL file from MySQL I use
phpMyAdmin and if I de-select the option "Extended Inserts" it generates an
insert per record instead of a single insert (what you want for SQL Server).
Basically, you're getting the error because you're trying

INSERT SomeTable VALUES ('a1', 'a2', a3'), ('b1', 'b2', b3')

when you want

INSERT SomeTable VALUES ('b1', 'b2', b3')
INSERT SomeTable VALUES ('a1', 'a2', a3')

Hope this helps!

Craig
Jul 20 '05 #2

P: n/a
Jet,
If you are a newbie to MS SQL Server 2000 and want to get up to speed
really quickly, our videos give you expert instruction on what you really
need to know about SQL Server. It's like reading a 1200 page book in a few
hours.
To answer your question below, a great way to do this is by using a DTS
package. It's easy to write, makes importing as simple as Excel, and can be
re-used.

For full info and examples of using a DTS package, download our videos at
www.technicalVideos.net
Best regards,
Chuck Conover
www.TechnicalVideos.net

"jet" <je*********@yahoo.com> wrote in message
news:c3**************************@posting.google.c om...
Hi,

Maybe this is an easy task, but I'm having a really hard time figuring
out how to do this. I'm a complete newbie to SQL Server.

I have a database dump file from MySQL that's in .sql format. I'm
trying to figure out how to import that into SQL Server 2000 so that
I'll be able to manipulate it in a gui format, rather than command
line. I can't find any import that takes a .sql file. I've been
trying to load it into the query analyzer and am also having problems
with that. Initially I had problems because there were question marks
within some of my data. I've removed those but when I run the query I
still get a bunch of syntax errors. Looking at the errors, the syntax
seems correct.

Does anyone know of a way to import a .sql script without having to
import it into the query analyzer? It seems like it should be a
no-brainer..... but perhaps my brain is lacking... I don't know!

Thanks for the help!

--jet
the following are the errors that I get and the associated code:
-------------------------------------------------------------------------- --- Server: Msg 170, Level 15, State 1, Line 17
Line 17: Incorrect syntax near ','.

CODE: INSERT INTO answers VALUES
('travelMethodRadio','j**********@montana.com','te lemark'),

The second line is line 17, and it is followed by more insert values.
-------------------------------------------------------------------------- ---- Server: Msg 170, Level 15, State 1, Line 7093
Line 7093: Incorrect syntax near 'a'.

CODE: ('groupSlopeTravelText','k*********@jhmg.com','Thi s is
completely dependent on conditions and if it is a heavily used area or
a fairly pristine area'),

This is just one in a long list of insert values... no idea why there
is a problem with this particular one.
--------------------------------------------------------------------------

-----
Jul 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.