开发者

Insert using UDTs and returning the identity values

I wish to insert many rows of data into a table in SqlServer and was planning on using table valued parameters (for its performance when inserting 开发者_运维技巧100s of rows). See MSDN

The Msdn article shows me how to insert many rows from a C# application as well as the stored procedure to do this.

But what I am not sure of is, as to how to return the identity values for all the rows that I inserted, from the stored procedure back to the C# app? (I cannot update the UDT as it is readonly within the stored procedure)

Can I create a separate UDT to return the array of inserted identity values?


You could try out the OUTPUT clause - tbh, that MSDN reference gives you everything you need with examples so I won't paraphrase! You can just OUTPUT the required fields (i.e. the IDENTITY values & any other relevant info) back as a resultset..

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜