Closed dotqi closed 6 years ago
Please, provide program that you run and show program output (garbled). Show output as picture here.
Thank you.
Alex
db,err := sql.Open("odbc", "driver={sql server};server=127.0.0.1;port=1433;uid=sa;pwd=imissyou;database=HN_NCMS")
if err!=nil {
fmt.Println(err)
return
}
sqlCode := "select convert(varchar(200),'9你好8') as fvr,convert(nvarchar(200),'9你好8') as fnr"
rows,err := db.Query(sqlCode)
if err!=nil {
fmt.Println(err)
} else {
var fvr,fnr string
for rows.Next() {
err = rows.Scan(&fvr,&fnr)
fmt.Println(fvr,fnr)
}
rows.Close()
}
<-ticks
db.Close()
VALUES : "9����8 9你好8"
@admin87 I pretty sure that varchar is for storing ASCII characters - you cannot store Chinese in varchar. You need nvarchar to be able to store Chinese.
Alex
You're right to explain. Can there be a solution?
Can there be a solution?
I do not know what your particular problem is. But varchar only allows for maximum of 256 characters. That is not enough to encode Chinese characters. I would use nvarchar to store Chinese.
Alex
Thank you very much. It can be closed. I am thinking about it myself.
When the SQL2000 data column type is VARCHAR, save the Chinese language and the data extracted from general QUERY. How do we deal with this problem? Display block SRC DATA "a刘9" GET DATA a��9