1

我有一个SqlCommand

UPDATE table SET intColumn = intColumn + 1 WHERE id = @id

有没有办法获得intColumn相同的新价值SqlCommand

就像是

UPDATE table 
SET intColumn = intColumn + 1 
WHERE id = @id; 
SELECT intColumn

ExecuteScalar

例如:

Dim x as int32 = sqlCommand.ExecuteScalar("sql") 

x 是intColumn?的新值

4

1 回答 1

1

SQL 查询的框架应如下所示

    sqlCommand.ExecuteScalar("UPDATE table SET intColumn=intColumn+1 
                             OUTPUT INSERTED.intColumn
                             WHERE id=@id")
于 2012-06-12T09:25:42.063 回答