Home All Groups Group Topic Archive Search About

nvarchar(max) and corresponding SqlDbType

Author
2 Jan 2007 4:36 PM
Dmitriy Melikov
Hi All,

I am using nvarchar(max) as a parameter for a stored procedure in a SQL
Server 2005 database.
What is the corresponding SqlDbType in this case?

System.Data.SqlDbType.NVarChar is limited to 4,000 characters.
MSDN says, "Explicitly set the object when working with strings longer than
4,000 characters."

I am not sure what this means.

Thank you for your help.

Dmitriy.

Author
2 Jan 2007 4:46 PM
David Browne
Show quote
"Dmitriy Melikov" <DmitriyMeli***@discussions.microsoft.com> wrote in
message news:4D55D6C5-50B5-43F8-9C4D-0CFBB4376032@microsoft.com...
> Hi All,
>
> I am using nvarchar(max) as a parameter for a stored procedure in a SQL
> Server 2005 database.
> What is the corresponding SqlDbType in this case?
>
> System.Data.SqlDbType.NVarChar is limited to 4,000 characters.
> MSDN says, "Explicitly set the object when working with strings longer
> than
> 4,000 characters."
>
> I am not sure what this means.
>

I think it means that you can just access the parameter value directly,
either setting or getting a System.String. See, the example under "Using
Large Value Type Parameters"



Working with Large Value Types
http://msdn2.microsoft.com/en-us/library/a1904w6t.aspx

David
Author
2 Jan 2007 10:00 PM
Dmitriy Melikov
Thank you, David.

It is very helpful.

Another way to solve this problem is to use

Microsoft.SqlServer.Management.Smo.SqlDataType.NVarCharMax

as a SQL data type to create a SqlParameter.

Dmitriy.

Show quote
"David Browne" wrote:

>
>
> "Dmitriy Melikov" <DmitriyMeli***@discussions.microsoft.com> wrote in
> message news:4D55D6C5-50B5-43F8-9C4D-0CFBB4376032@microsoft.com...
> > Hi All,
> >
> > I am using nvarchar(max) as a parameter for a stored procedure in a SQL
> > Server 2005 database.
> > What is the corresponding SqlDbType in this case?
> >
> > System.Data.SqlDbType.NVarChar is limited to 4,000 characters.
> > MSDN says, "Explicitly set the object when working with strings longer
> > than
> > 4,000 characters."
> >
> > I am not sure what this means.
> >
>
> I think it means that you can just access the parameter value directly,
> either setting or getting a System.String. See, the example under "Using
> Large Value Type Parameters"
>
>
>
> Working with Large Value Types
> http://msdn2.microsoft.com/en-us/library/a1904w6t.aspx
>
> David
>
>

AddThis Social Bookmark Button