Closed hopestar closed 3 years ago
Learn T-SQL a bit better. Please review the docs for the update
clause: https://docs.microsoft.com/en-us/sql/t-sql/queries/update-transact-sql?view=sql-server-ver15
What you want is:
update t set
xx=1
output
inserted.*
from
table t
where
t.id = 7
;
Hello,
I think what you are looking for is the Exec method.
Use it instead of Query
.
Please be aware that LastInsertId
cannot function properly with SQL Server.
You would need to use Query
again, and an OUTPUT
clause or a second statement:
INSERT ...
;SELECT SCOPE_IDENTITY()
Learn T-SQL a bit better. Please review the docs for the
update
clause: https://docs.microsoft.com/en-us/sql/t-sql/queries/update-transact-sql?view=sql-server-ver15What you want is:
update t set xx=1 output inserted.* from table t where t.id = 7 ;
yes, thank you very much ~
@hopestar - if you're all set here, can you make the issue closed?
hello ~ could you tell me how to get the update result? the query like "update table set xx=1 WHERE id=7" i using rows.Next() , but it always return false. how to get the result like rows.RowsAffected ? thanks.