/// <summary>
        ///     Declares a new Variable of the Given SQL Type by using its length
        /// </summary>
        /// <param name="query">The query.</param>
        /// <param name="name">The name.</param>
        /// <param name="type">The type.</param>
        /// <param name="length">The length.</param>
        /// <param name="value">The value.</param>
        /// <returns></returns>
        public static RootQuery DeclareVariable(this RootQuery query, string name, SqlDbType type, int length = int.MaxValue,
                                                object value = null)
        {
            var sqlName = name;

            if (!sqlName.StartsWith("@"))
            {
                sqlName = "@" + sqlName;
            }
            var typeName = type.ToString();

            if (new SqlParameter("xxx", type).Size > 0)
            {
                typeName = "(MAX)";
            }

            query = query.QueryText("DECLARE {0} {1};", sqlName, typeName);
            if (value != null)
            {
                query = query.SetVariable(sqlName, value);
            }
            return(query);
        }