实现思路:拼接sql,返回结果集。

declare @p1 int
set @p1=0
declare @p2 varchar(1024)
set @p2=''
exec proc N'1',N'2',N'3',N'4',N'5',N'6',N'7',@p1 output,@p2 output
select @p1,@p2

golang实现

//参数拼接
params := fmt.Sprintf("N'%s',N'%s',N'%s',N'%s',N'%s',N'%s',N'%s'",
"1","2","3","4","5","6","7")
sqlRaw := `
declare @p1 int
set @p1=0
declare @p2 varchar(1024)
set @p2=''
exec proc `+params+`,@p1 output,@p2 output
select @p1,@p2
`
rows,err:=sqlServer.Query(sqlRaw)
if err != nil {
log.Fatal(err)
}
var onReturn int
var onMessage string
for rows.Next(){
rows.Scan(&onReturn,&onMessage)
}
rows.Close()
log.Println(onReturn,onMessage)

ps:如果是返回结果集的存储过程,直接Query('exce proc')即可,当做普通的查询即可