using the "While" statement with "Begin Transaction and Commit Transaction"

  • I develope in C# and would like to use tsql transaction in the database instead of .NET TransactionScope etc. If I am submitting one record to several tables, I am able to do this. The problem is how best can I submit batch records (or say more than 2 to 100) using tsql stored procedure? I normally use transactionscope and foreach statement in C#. I desperately need help, or I am missing something?

  • You better to stay with using TransactionScope :-).

    It is not quite clear what are you trying to do in one transaction.

    You can submit batch of records into stored proc in XML format, parse it inside of stored proc and write everything into the database in a single transaction. But why do you really want to do it?

    _____________________________________________
    "The only true wisdom is in knowing you know nothing"
    "O skol'ko nam otkrytiy chudnyh prevnosit microsofta duh!":-D
    (So many miracle inventions provided by MS to us...)

    How to post your question to get the best and quick help[/url]

  • If you are using SQL 2008 and (I believe) .Net 3, you can use the table valued parameter.

    http://www.codeproject.com/KB/cs/CSharpAndTableValueParams.aspx

    http://msdn.microsoft.com/en-us/library/bb675163.aspx

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply