package main

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

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

func main() {
	connStr := "server=192.168.10.61;user id=pond;password=Ehongmd2025;port=1433;database=CONFIG;encrypt=disable"
	db, err := sql.Open("sqlserver", connStr)
	if err != nil {
		log.Fatal("Error opening database: ", err)
	}
	defer db.Close()

	rows, err := db.Query("SELECT TOP 1 * FROM CONFIG.dbo.LOCATION_RAP")
	if err != nil {
		log.Fatal("Query error: ", err)
	}
	defer rows.Close()

	cols, err := rows.Columns()
	if err != nil {
		log.Fatal("Columns error: ", err)
	}
	
	colTypes, err := rows.ColumnTypes()
	if err != nil {
		log.Fatal("ColumnTypes error: ", err)
	}

	fmt.Println("Columns in LOCATION_RAP:")
	for i, col := range cols {
		fmt.Printf("- %s (Type: %s)\n", col, colTypes[i].DatabaseTypeName())
	}
}
