Click here to Skip to main content
15,896,557 members
Articles / Database Development / SQL Server

Asynchronous T-SQL Execution Without Service Broker

Rate me:
Please Sign up or sign in to vote.
5.00/5 (14 votes)
15 Sep 2008CPOL6 min read 147.4K   4.7K   48  
Set of SQL CLR Stored Procedures to execute T-SQL asynchronously without using a Service Broker.
using System;
using System.Collections.Generic;
using System.Text;

namespace SqlClrLib.Model
{
    /// <summary>
    /// Holds thread execution result
    /// </summary>
    [Serializable]
    class ResultItem
    {
        public ResultItem(ThreadSql sql)
        {
            Key = sql.Key;
            Success = sql.Exception == null;
            RunTime = Convert.ToInt32(sql.RunTime);
            if (sql.Exception != null)
            {
                ErrorMessage = sql.Exception.Message;
                ErrorStack = string.Format("{0}:\n{1}", sql.Exception.GetType().FullName, sql.Exception.StackTrace);
            }
            else
            {
                ErrorMessage = string.Empty;
                ErrorStack = string.Empty;
            }
        }
        public string Key;
        public bool Success;
        public int RunTime;
        public string ErrorMessage;
        public string ErrorStack;
    }

}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior) VORLAN Group, Inc.
United States United States
writing code for the past 20 years, and now decided to share some thoughts. Smile | :)
Also known as Oleg Vorkunov.

Comments and Discussions