473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

clr sql server function

xke
This is my function:

<Microsoft.SqlServer.Server.SqlFunction()_
Public Shared Function RegExMatch(ByVal pattern As String, _
ByVal matchString As String) As Boolean

Dim r1 As Regex = New Regex(pattern.TrimEnd(Nothing),
RegexOptions.Compiled)
Return r1.Match(matchString).Success
End Function
I have noticed that the call:

select dbo.RegexMatch('some_reg_exp_pattern', my_match_content)

will trim my_match_content to 4000 chars.
It means everything over 4000 chars will be ignored. I guess this is
happening because of mapping string to a varchar - which may have a
max 4000 chars.

And my_match_content is actually a column varchar(max).

How can I adapt the function to support biger size strings?
Thanks,
xke

Mar 14 '07 #1
2 1254
xke
Actually I test this function under Test Scripts

<Microsoft.SqlServer.Server.SqlFunction()_
Public Shared Function TestF(ByVal simple_string As String) As
Boolean
dim strTest as string
strTest = "123"
Return true
End Function

The test is based on select dbo.TestF(N'some text')

I put a breakpoint at strTest = "123", anyway 'some text' comes
nvachar with a 4000 maximum.
If I put a longer text it will get into my function trimmed to 4000.

Do you know any workaround?
Thanks,
xke
On Mar 14, 2:47 pm, "xke" <xke...@gmail.comwrote:
This is my function:

<Microsoft.SqlServer.Server.SqlFunction()_
Public Shared Function RegExMatch(ByVal pattern As String, _
ByVal matchString As String) As Boolean

Dim r1 As Regex = New Regex(pattern.TrimEnd(Nothing),
RegexOptions.Compiled)
Return r1.Match(matchString).Success
End Function

I have noticed that the call:

select dbo.RegexMatch('some_reg_exp_pattern', my_match_content)

will trim my_match_content to 4000 chars.
It means everything over 4000 chars will be ignored. I guess this is
happening because of mapping string to a varchar - which may have a
max 4000 chars.

And my_match_content is actually a column varchar(max).

How can I adapt the function to support biger size strings?
Thanks,
xke

Mar 14 '07 #2
xke
And the solution is .....

<Microsoft.SqlServer.Server.SqlFunction()_
Public Shared Function RegExMatch(ByVal pattern As String, _
ByVal matchString As SqlChars) As Boolean

Dim r1 As Regex = New Regex(pattern.TrimEnd(Nothing),
RegexOptions.Compiled)
Return r1.Match(New String(matchString.Value)).Success
End Function

Found out from a great article written by David Banister
http://msdn.microsoft.com/msdnmag/is...x/default.aspx

that sqlChars is varchar(max)

Mar 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ken Lindner | last post by:
I have a need to become familiar with SQL Server 2000 for work. Needless to say I am new to SQL Server any version, but not IT in general. My employer has provided me with the SQL Server 2000...
13
by: Jeager | last post by:
Why is it, Microsoft manage to write operating systems and office applications with every bell and whistle facility known to man. Yet, even after years and years of development they still cannot...
1
by: Ryan McLean | last post by:
Hi everyone! What is happening is the method: sub_btnSubmitClicked is being executed every time any other object with a Handler is executed. I am trying not to use the withevents and handles...
0
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2...
10
by: tlyczko | last post by:
Hello, We have Access databases (backends) that will eventually be consolidated into a SQL Server database, to facilitate data reporting, analysis, etc. Some queries in one Access database...
14
by: Marcus | last post by:
I have a function that simply returns TRUE if it can connect to a particular Sql Server 2005 express, or FALSE if it cannot. I am getting some strange error codes returned when the computer that...
2
by: Jobs | last post by:
Download the JAVA , .NET and SQL Server interview with answers Download the JAVA , .NET and SQL Server interview sheet and rate yourself. This will help you judge yourself are you really worth of...
6
by: den 2005 | last post by:
Hi everybody, Question 1: How do you set the values from server-side to a client-side control or how do you execute a javascript function without a button click event? Question 2: How do you...
7
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function Body_Onload() ' create the object Set obj = Server.CreateObject("UploadImage.cTest") ' use method of the object...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.