Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 CLR UDT Max byte size

Author  Topic 

stathis30_2000
Starting Member

23 Posts

Posted - 2007-08-24 : 08:34:52
Hello,

I need some help working with CLR UDTs. I have created two UDTs called trajectory and point. Each trajectory consists of a list of points. Each point consists of three members : lon( type double), lat( type double) and datetime.

I have written my own IBinarySerialize.Write method for the trajectory type which is the following:

Dim maxSize As Integer = 4000
Dim value As String = ""
Dim paddedvalue As String

Dim i As Integer
Dim pt As Point

For i = 0 To point_list.Count - 1

pt = point_list.Item(i)

If i = 0 Then
value = value & pt.X & "|" & pt.Y & "|" & pt.D

Else

value = value & ">" & pt.X & "|" & pt.Y & "|" & pt.D
End If

Next

paddedvalue = value.PadRight(maxSize, ControlChars.NullChar)

For i = 0 To paddedvalue.Length - 1 Step 1
w.Write(paddedvalue(i))
Next

If I try to store 225 points for a trajectory then the following error occurs:

System.Data.SqlTypes.SqlTypeException: The buffer is insufficient. Read or write operation failed.

Why is that happening? The limit size for a UDT is 8000bytes. Each point needs 24Bytes (2*SizeOf(double) + sizeOf(Datetime)).

Please help
ST

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-25 : 04:32:00
The new VARCHAR(MAX) datatype is 2 gig



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

stathis30_2000
Starting Member

23 Posts

Posted - 2007-08-25 : 05:32:08
Should I replace my udt with the varchar type? I have created some methods for my udts, how can I use them with varchar? Can I cast a varchar record to my udt class? I need some help on that ..

Thanks
Go to Top of Page
   

- Advertisement -