Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7538725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T07:11:38+00:00 2026-05-30T07:11:38+00:00

I am returning a static string from a stored procedure (in SQL Server 2008)

  • 0

I am returning a static string from a stored procedure (in SQL Server 2008) as below:

select 'abcdefgh.........xyz'

If the static string length is exceeding more than some limit (eg:8kb) then only partial string (eg:7kb) is returned to the .net apps.

Though I tried in different ways like assigning static string to varchar(max) and selecting the variable, is still returning only partial string.

I should return complete string which could be of max of 5mb. So, main concerns:

  1. What is the max string length I can return from a stored procedure
  2. How to return 5 mb string from stored procedure to .net apps.

I request someone can help me to resolve this issue.
please find the code below

 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;
                }               
            }

Thanks in advance geeks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T07:11:39+00:00Added an answer on May 30, 2026 at 7:11 am

    Thanks for support, I found 1 fix for this at
    http://www.sqlservercentral.com/Forums/Topic350590-145-1.aspx

    Fix is, declare a variable, and should be initlized to empty string and concatenated with the main string.

      DECLARE @test varchar(MAX);
    set @test =''
     select  @test = @test + '<Invoice>.....'
    

    If the string length is <8000 it will work without the above approach.

    Thanks all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a question about returning efficiently strings and chars from a string array
I've below stored proc: CREATE OR REPLACE PROCEDURE demo.run_demo(v_sql IN VARCHAR2, return_code OUT number)
Instead of returning a common string, is there a way to return classic objects?
I am returning XML data from the Yahoo GeoPlanet web service using HttpWebRequest .
I am returning a List from my WCF method. In my client code, it's
I'm trying to execute a simple stored procedure with Spring/Hibernate using Annotations. Here are
I'm having trouble returning arrays from a custom method. It compiles fine but I
I have a string that i am trying to extract patterns from, the string
From ValueType.cs **Action: Our algorithm for returning the hashcode is a little bit complex.
In a function in my C++ DLL, I'm returning a std::string to my c#

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.