golang操作sqlserver 语句包含 insert update select ,该如何获取最后select的数据
需要向数据库添加一条数据,并返回自增的一个id,然后通过这个id更新这条数据里的某条数据,最后并返回这个id。该如何获取这个id。sql语句如下
DECLARE @ID int;insert into tablename(col1, col2, col3)values(?,?,?);
Select @ID=@@IDENTITY;update tablename set col1=col1+’,’+CONVERT(varchar,@ID) where id=@ID;SELECT @ID