db.ExecContext(ctx, `
delete from Invoice
where
TimeCreated < @end
and TimeCreated >= @start;`,
sql.Named("start", startTime),
sql.Named("end", endTime),
)
官方示例如上,连接mssql执行,会提示参数错误。
尝试把SQL语句中的 @ 改成 : 后,执行成功。
如下:
db.ExecContext(ctx, `
delete from Invoice
where
TimeCreated < :end
and TimeCreated >= :start;`,
sql.Named("start", startTime),
sql.Named("end", endTime),
)