-
Notifications
You must be signed in to change notification settings - Fork 523
Open
Description
Using BulkCopy to insert Chinese data into the table in batches can be successfully stored in the database,however, the Chinese characters stored in the database are garbled. For example, the string "你好" becomes "浣犲ソ " in the database.
The type of the field is varchar, and according to requirements, nvarchar cannot be used instead.
Please tell me how to solve this requirement, thank you.
stmt, err := txn.Prepare(mssql.CopyIn("t_batch_update", mssql.BulkOptions{}, "id", "name"))
if err != nil {
fmt.Println(err)
return
}
for i := 0; i < 10; i++ {
_, err = stmt.Exec(i, "你好")
if err != nil {
fmt.Println(err)
return
}
}
result, err := stmt.Exec()
if err != nil {
fmt.Println(err)
return
}
err = stmt.Close()
if err != nil {
fmt.Println(err)
return
}
err = txn.Commit()
if err != nil {
fmt.Println(err)
return
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels