21 lines
409 B
Go
21 lines
409 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
_ "github.com/denisenkom/go-mssqldb"
|
||
|
)
|
||
|
|
||
|
func getColumnNames(tableName string) (string, error) {
|
||
|
ctx := context.Background()
|
||
|
checkIsDatabaseAlive()
|
||
|
tsql := "SELECT * FROM " + tableName
|
||
|
rows, _ := db.QueryContext(ctx, tsql)
|
||
|
collection, _ := rows.Columns()
|
||
|
var toReturn string
|
||
|
for _, element := range collection {
|
||
|
toReturn += element + "."
|
||
|
}
|
||
|
return toReturn, nil
|
||
|
}
|