package main

import (
	"database/sql"
	"fmt"
	"log"

	_ "github.com/microsoft/go-mssqldb"
)

func main() {
	connString := "server=127.0.0.1;user id=sa;password=Ehong@2025;database=EHONGDB;encrypt=disable"
	db, err := sql.Open("sqlserver", connString)
	if err != nil {
		log.Fatal(err)
	}
	defer db.Close()

	rows, err := db.Query("SELECT TOP 1 stnpy, notpay_count, stnon, non_count FROM EHONGDB.dbo.hps_ctmain")
	if err != nil {
		// If columns don't exist, try to list all columns to find similar ones
		log.Println("Error querying specific columns:", err)
		rows2, err2 := db.Query("SELECT TOP 1 * FROM EHONGDB.dbo.hps_ctmain")
		if err2 != nil {
			log.Fatal(err2)
		}
		defer rows2.Close()
		cols, _ := rows2.Columns()
		fmt.Println("Available columns in hps_ctmain:", cols)
		return
	}
	defer rows.Close()

	fmt.Println("Columns stnpy, notpay_count, stnon, non_count exist.")
}
