Home All Groups Group Topic Archive Search About

varchar(8000), varchar(max) and other sizes of varchar truncated to varchar(255)

Author
16 Sep 2005 5:17 AM
HB
I am using VS 2005 and trying to execute a stored procedure in SQL 2005.
This SP takes a parameter @var1 of type varchar(8000). When I debug the SP
via VS 2005 debugger and step through the SP code, the value of @var1 is
truncated containing only the first 255 characters. I tried replacing the
size of varchar to 1000, 600, (max, which is possible in SQL 2005) but VS
2005 debugger still truncates the value to 255 characters. If I pass <= 255
characters, everything works okay.

More troubling is the difference in behavior of "execution of this SP in VS
2005" versus the "execution of this SP in SQL Management Studio." Since I
cannot debug my SP in SQL Management Studio, I passed a large string of 2000
characters to @var1 in SQL Mgmt Studio and executed the SP; everything
worked fine. I tried larger sizes as well in SQL Mgmt Studio and everything
is fine. So, I do not think the code in my SP is a culprit. But, I am also
not sure who the real culprit is.

Both the SQL Server 2005 and VS 2005 are installed on the same machine.

I have tried some obvious things. Recompiling SP, Start/Restart SQL Server,
Restart machine etc. But, I am still experiencing the same problem.

Could somebody advice me what I should do to fix this problem?

Thanks

Author
16 Sep 2005 9:14 AM
R.D
HB
you are right. There is absolutely no problem with SP.
Problem appears to be in defining the data type in front end.
See that your front end data definition is correct. i:e you did not use
appropriate data type in the front end/ado/jscript to hold that value
Regards
R.D


Show quote
"HB" wrote:

> I am using VS 2005 and trying to execute a stored procedure in SQL 2005.
> This SP takes a parameter @var1 of type varchar(8000). When I debug the SP
> via VS 2005 debugger and step through the SP code, the value of @var1 is
> truncated containing only the first 255 characters. I tried replacing the
> size of varchar to 1000, 600, (max, which is possible in SQL 2005) but VS
> 2005 debugger still truncates the value to 255 characters. If I pass <= 255
> characters, everything works okay.
>
> More troubling is the difference in behavior of "execution of this SP in VS
> 2005" versus the "execution of this SP in SQL Management Studio." Since I
> cannot debug my SP in SQL Management Studio, I passed a large string of 2000
> characters to @var1 in SQL Mgmt Studio and executed the SP; everything
> worked fine. I tried larger sizes as well in SQL Mgmt Studio and everything
> is fine. So, I do not think the code in my SP is a culprit. But, I am also
> not sure who the real culprit is.
>
> Both the SQL Server 2005 and VS 2005 are installed on the same machine.
>
> I have tried some obvious things. Recompiling SP, Start/Restart SQL Server,
> Restart machine etc. But, I am still experiencing the same problem.
>
> Could somebody advice me what I should do to fix this problem?
>
> Thanks
>
>
>
>
>
Author
16 Sep 2005 10:27 AM
Erland Sommarskog
HB (nospam@microsoft.com) writes:
> I am using VS 2005 and trying to execute a stored procedure in SQL 2005.
> This SP takes a parameter @var1 of type varchar(8000). When I debug the
> SP via VS 2005 debugger and step through the SP code, the value of @var1
> is truncated containing only the first 255 characters. I tried replacing
> the size of varchar to 1000, 600, (max, which is possible in SQL 2005)
> but VS 2005 debugger still truncates the value to 255 characters. If I
> pass <= 255 characters, everything works okay.

Is the value really truncated, or does it just look like it is truncated
in the Visual Studio debugger? I would assume that it is the latter.

There might be a VS setting for this, but I don't know VS very well.

In any case, questions about SQL 2005 should be asked in the SQL 2005
newsgroups, access information here:
http://go.microsoft.com/fwlink/?linkid=31765.

However, this sounds like a VS issue to me. There are no newsgroups for
VS 2005, but there are web forums at http://forums.microsoft.com.

--
Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
Author
16 Sep 2005 3:26 PM
HB
Thanks Erland and R.D.

It appears that VS 2005 (at least in my settings) does SHOW the truncated
value (255 chars) when I type @var1 in the immediate window. My SP is
crashing due to other reasons.

I also do not know where to change the options in VS 2005 so I see the full
string.

BTW R.D., both in SQL and in VS, the datatype and the of @var1 is the same,
and I changed at both the places whenever I changed at one of them.

Show quote
"Erland Sommarskog" <esq***@sommarskog.se> wrote in message
news:Xns96D37E751E844Yazorman@127.0.0.1...
> HB (nospam@microsoft.com) writes:
> > I am using VS 2005 and trying to execute a stored procedure in SQL 2005.
> > This SP takes a parameter @var1 of type varchar(8000). When I debug the
> > SP via VS 2005 debugger and step through the SP code, the value of @var1
> > is truncated containing only the first 255 characters. I tried replacing
> > the size of varchar to 1000, 600, (max, which is possible in SQL 2005)
> > but VS 2005 debugger still truncates the value to 255 characters. If I
> > pass <= 255 characters, everything works okay.
>
> Is the value really truncated, or does it just look like it is truncated
> in the Visual Studio debugger? I would assume that it is the latter.
>
> There might be a VS setting for this, but I don't know VS very well.
>
> In any case, questions about SQL 2005 should be asked in the SQL 2005
> newsgroups, access information here:
> http://go.microsoft.com/fwlink/?linkid=31765.
>
> However, this sounds like a VS issue to me. There are no newsgroups for
> VS 2005, but there are web forums at http://forums.microsoft.com.
>
> --
> Erland Sommarskog, SQL Server MVP, esq***@sommarskog.se
>
> Books Online for SQL Server SP3 at
> http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
>

AddThis Social Bookmark Button