0

I am trying to import data from a MySQL database into a SQL Server database. I have created a DSN and am able to successfully connect with the target database. But when I try to import I get the following error in the screen shot:

enter image description here

Please advise on what am I doing wrong.

CREATE TABLE [dbo].[TP_Magri_live_stats_1] 
(
    [Dated] VARCHAR(20) NOT NULL,
    [plateform_base] VARCHAR(255),
    [DefaultProfiles] VARCHAR(255),
    [resubscribers] VARCHAR(255),
    [SubFromOBD] VARCHAR(255),
    [SubFromSMS] VARCHAR(255),
    [SubFromIVR] VARCHAR(255),
    [SubFromUSSD] VARCHAR(255),
    [SubFromWEB] VARCHAR(255),
    [TotalSubs] VARCHAR(255),
    [TotalUnsubs] VARCHAR(255),
    [MornOBDPickupCount] VARCHAR(255),
    [MornOBDConsumedMins] VARCHAR(255),
    [OBDEngUsers] VARCHAR(255),
    [OBDEngMins] VARCHAR(255),
    [HelpRequests] VARCHAR(255),
    [TotalSms] VARCHAR(255),
    [TotalCalls] VARCHAR(255),
    [UniqueCallers] VARCHAR(255),
    [TotalMins] VARCHAR(255),
    [SubTotalCalls] VARCHAR(255),
    [SubUniqueCallers] VARCHAR(255),
    [SubTotalMins] VARCHAR(255),
    [RepeatIntUser] VARCHAR(255),
    [UssdRefCalls] VARCHAR(255),
    [SubCount] VARCHAR(255),
    [UnsubCount] VARCHAR(255),
    [ResubCount] VARCHAR(255),
    [MauUsers] VARCHAR(255),
    [TenDaysUsage] VARCHAR(255),
    [DauUsers] VARCHAR(255),
    [SameDayUnsubs] VARCHAR(255),
    [MonthlyActiveUsers] VARCHAR(255),
    [DauMornOBD] VARCHAR(255),
    [MauMornOBD] VARCHAR(255)
)
8
  • 1
    post the query! Commented Nov 27, 2019 at 6:05
  • Query added to the original question Commented Nov 27, 2019 at 6:08
  • Why is everything of type VARCHAR(255) - even when the name of column like SubCount really seems to indicate it's numerical value?!?!? You should always use the most appropriate datatype and not just store everything as a string Commented Nov 27, 2019 at 6:09
  • Actually this is from a another system...they are just dumping data like that Commented Nov 27, 2019 at 6:11
  • 1
    So, this has nothing to do with MySQL then; you have a syntax error in a SQL Server query? Commented Nov 27, 2019 at 6:12

1 Answer 1

1

Judging from the error, you're using a MySQL driver to execute queries on SQL Server.

It could just be the that SQL Server's non SQL-standard compliant use of square brackets around entity names is the problem.

Either:

  1. Use a SQL Server driver
  2. Don't put square brackets in the output (they are only needed if there are spaces in the entity names, which is a bad idea anyway)
Sign up to request clarification or add additional context in comments.

5 Comments

How do I use an SQL server driver to connect to MySQL...I am using a mysql connector to create a DSN and then using that system level DSN to connect to MySQL database for importing the data in MS SQL Server
@Amin Baig , It would help if you could add step by step screenshots of what you are doing
@Amin stating the obvious, use a MySQL driver to connect to MySQL and a SQL Server driver to connect to SQL Server
Guys...did exactly the same...connecting to the respective databases accordingly but get an error when I try to import.
@Amin, Please check the following links MSSQLTIPS and/or SSMA I have never tried doing this, I do it the hard way MYSQL->Flat Files and then Flat Files->SQL SERVER using SSIS. If the data that you have is huge, split the flat file in chunks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.