我从存储过程(在 SQL Server 2008 中)返回一个静态字符串,如下所示:
select 'abcdefgh.........xyz'
如果静态字符串长度超过某个限制(例如:8kb),则仅将部分字符串(例如:7kb)返回给 .net 应用程序。
尽管我尝试了不同的方式,例如将静态字符串分配给varchar(max)
和选择变量,但仍然只返回部分字符串。
我应该返回最大为 5mb 的完整字符串。所以,主要担心:
- 我可以从存储过程返回的最大字符串长度是多少
- 如何将 5 mb 字符串从存储过程返回到 .net 应用程序。
我请求有人可以帮助我解决这个问题。请在下面找到代码
using (SqlCommand command = new SqlCommand(Source.GetExportRecordSP, Connection))
{
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add(new SqlParameter("@CandidateRecordID ", SqlDbType.NVarChar, 32)).Value = record;
try
{
if (Connection.State != ConnectionState.Open)
{
Connection.Open();
}
using (SqlDataReader reader = command.ExecuteReader())
{
if(reader.Read())
{
xmlRecord = new XmlDocument();
xmlRecord.LoadXml(reader.GetString(0));
}
}
}
catch (Exception Ex)
{
Logging.WriteError(string.Format("Error while retrieving the Record \"{0}\" details from Database. Exception: {1} ", Ex.ToString()));
throw;
}
}
提前感谢极客。