2016-03-03 14:19:17 +00:00
|
|
|
package mssql
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
|
|
|
)
|
|
|
|
|
|
|
|
// SplitSQL is used to split a series of SQL statements
|
|
|
|
func SplitSQL(sql string) []string {
|
|
|
|
parts := strings.Split(sql, ";")
|
|
|
|
out := make([]string, 0, len(parts))
|
|
|
|
for _, p := range parts {
|
|
|
|
clean := strings.TrimSpace(p)
|
|
|
|
if len(clean) > 0 {
|
|
|
|
out = append(out, clean)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return out
|
|
|
|
}
|
|
|
|
|
|
|
|
// Query templates a query for us.
|
|
|
|
func Query(tpl string, data map[string]string) string {
|
|
|
|
for k, v := range data {
|
2022-08-03 19:22:48 +00:00
|
|
|
tpl = strings.ReplaceAll(tpl, fmt.Sprintf("{{%s}}", k), v)
|
2016-03-03 14:19:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return tpl
|
|
|
|
}
|