Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect SQL Syntax - Unclosed quotation mark after the character string #51

Open
huaguoping opened this issue Jan 16, 2017 · 1 comment

Comments

@huaguoping
Copy link

huaguoping commented Jan 16, 2017

Hi, everyone.
I encountered a strange problem.When I run the same code on test platform using the same conf, it work well. Once I run the same code on production platform, I got the following error:

General SQL Server error: Check messages from the SQL Server

Msg 170, Level 15
General SQL Server error: Check messages from the SQL Server

Msg 105, Level 15, State 1
Server 'SERVER', Line 24
        Unclosed quotation mark before the character string '<E5><90>?'.

Msg 170, Level 15, State 1
Server 'SERVER', Line 24
        Line 24: Incorrect syntax near '<E5><90>?'.

My code is :

_, err := db.Exec(`
		INSERT INTO Table (
			field1
			, field2
			, field3
			, field4
			, field5
			, field6
			, field7
			, field8
			, field9) 
			VALUES (
				?
				,?
				,?
				,?
				,?
				,?
				,?
				,?
				,?)`, info.TopMarketId, Info.MarketId, Info.GoodsId, Info.GoodsAttribute, Info.TrackDate, Info.Value, Info.TimeCreated, Info.TimeLastUpdated, Info.Type)
	if err != nil {
		log.Println("DB Exec failed: ", err.Error())
		return err
	}

Anyone can help?Thank you very much : )

@ianic
Copy link
Contributor

ianic commented Jan 16, 2017

In case like this I will fire up SQL Server Profiler and catch the exact command which is sent to the mssql.
The other way is to switch on freetds logging and find there the command:

export TDSDUMP=/tmp/freetds.log
./my_app
...
less /tmp/freetds.log

Once you find what is exactly sent to the mssql it should be obvious where we failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants