471,317 Members | 2,596 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,317 software developers and data experts.

nvarchar(max) sql data type equivalen in c#

skg
i am writing a UDF which takes nvarchar(max) as input parameter. Can any one
tell me what is the equivalent of this data type in C#.
Thx
Feb 2 '06 #1
2 12726
There isn't one. You can have a 'string', but you wouldn't be able to
specify a maximum length to it, and you wouldn't need to specify that it can
hold unicode data.

"skg" <sk*@yahoo.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
i am writing a UDF which takes nvarchar(max) as input parameter. Can any
one
tell me what is the equivalent of this data type in C#.
Thx

Feb 2 '06 #2
skg
Thanks Marina !!! I posted this in public.SQLServer.programming newsgroup
today, sorry, don't know how to copy the link to that thread for you.
But here is what i am seeing when i do return Length of the input string i
get 4000 always. i am concerned i am loosing bytes when calling the UDF.
Using SQLChar i get correct size. Here is my code snippet. i am i doing
something wrong.
using System;
using System.Data;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Collections;
using System.Security.Cryptography;
using System.Text;

public partial class UserDefinedFunctions
{

[SqlFunction(IsDeterministic = true, IsPrecise = true, DataAccess =
DataAccessKind.None)]
public static SqlInt32 GetLength(string sInputString)
{
return (SqlInt32)sInputString.Length;
}
};
select top 10
id,datalength(blobfield)[SQLSize],dbo.GetLength(blobfield)[UDFSize] from
Table1 where datalength(blobfield) > 8000
id SQLSize UDFSize
----------- -------------------- -----------
2 49874 4000
13 28860 4000
62868 8166 4000
62873 9702 4000
62874 36546 4000

"Marina Levit [MVP]" <so*****@nospam.com> wrote in message
news:ex****************@TK2MSFTNGP09.phx.gbl...
There isn't one. You can have a 'string', but you wouldn't be able to
specify a maximum length to it, and you wouldn't need to specify that it
can hold unicode data.

"skg" <sk*@yahoo.com> wrote in message
news:Or**************@tk2msftngp13.phx.gbl...
i am writing a UDF which takes nvarchar(max) as input parameter. Can any
one
tell me what is the equivalent of this data type in C#.
Thx


Feb 2 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by gordy | last post: by
6 posts views Thread by New MSSQL DBA | last post: by
5 posts views Thread by haidani | last post: by
6 posts views Thread by =?Utf-8?B?R3JlZw==?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.