You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In sqlserver2008, as the code sample below, I select "name""name1" from the test table, if the "name1" is NULL, the "name1" value will be the same as "name"
// the code sample
func testDB(db *sql.DB) {
db.Exec("if object_id(N'test',N'U') is not null drop table test")
db.Exec("create table test(id int not null primary key, name varchar(20), name1 varchar(20) )")
for i := 0; i < 4; i++ {
name := "name" + strconv.Itoa(i)
name1 := strconv.Itoa(i)
if i%2 == 1 {
db.Exec("insert into test(id, name, name1) values(?, ?, ?)", i, name, name1)
} else {
db.Exec("insert into test(id, name) values(?, ?)", i, name)
}
}
rows, _ := db.Query("select * from test")
for rows.Next() {
var id int
var name, name1 string
rows.Scan(&id, &name, &name1)
log.Printf("result: %d, %s, %s ", id, name, name1)
}
}
The text was updated successfully, but these errors were encountered:
In sqlserver2008, as the code sample below, I select "name""name1" from the test table, if the "name1" is NULL, the "name1" value will be the same as "name"
The text was updated successfully, but these errors were encountered: