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()

	// Check link between hps_ctmain and product
	rows, err := db.Query("SELECT TOP 1 product_id, brand_no, fml_no FROM EHONGDB.dbo.hps_ctmain")
	if err != nil {
		log.Println("Error querying hps_ctmain for product fields:", err)
	} else {
		cols, _ := rows.Columns()
		fmt.Println("Columns in hps_ctmain for product linking:", cols)
		rows.Close()
	}

	// Check product_family columns
	rows2, err := db.Query("SELECT TOP 1 * FROM EHONGDB.dbo.product_family")
	if err != nil {
		log.Println("Error querying product_family:", err)
	} else {
		cols, _ := rows2.Columns()
		fmt.Println("Columns in product_family:", cols)
		rows2.Close()
	}

    // Check product_brand if exists
    rows3, err := db.Query("SELECT TOP 1 * FROM EHONGDB.dbo.product_brand")
	if err != nil {
		log.Println("Error querying product_brand:", err)
	} else {
		cols, _ := rows3.Columns()
		fmt.Println("Columns in product_brand:", cols)
		rows3.Close()
	}
}
