Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
CLR Integration and Programming.
»
new to clr Integration,
new to clr Integration,
Rate Topic
Display Mode
Topic Options
Author
Message
gissah
gissah
Posted Thursday, June 07, 2012 1:14 PM
SSC Rookie
Group: General Forum Members
Last Login: Today @ 4:43 PM
Points: 43,
Visits: 155
I am creating a small project to read match regex from sql,
.cs file
using System;
using System.Data;
using System.Data.Sql;
using System.Data.SqlTypes;
using Microsoft.SqlServer.Server;
using System.Collections;
using System.Text.RegularExpressions;
public partial class RegExBase
{
[SqlFunction(IsDeterministic = true, IsPrecise = true)]
public static bool RegexSHIP(string matchString, string pattern)
{
Regex r1 = new Regex(pattern.TrimEnd(null));
return Regex.Match(matchString.TrimEnd(null), pattern.TrimEnd(null)).Success;
}
};
Test.sql
select * from [databasename].[dbo].tablename as P, [databasename].[dbo].tablename as S
where P.UserID = 'Rep'
and S.UserID = P.UserID
and dbo.RegexSHIP('T_SHIP_123456.txt', S.Pattern) = 1
I have enable clr, created function but still getting the attach error and help to solve that.
Thanks
Post Attachments
error.docx
(
3 views,
177.64 KB
)
Post #1312741
Lowell
Lowell
Posted Thursday, June 07, 2012 1:19 PM
SSChampion
Group: General Forum Members
Last Login: Today @ 8:39 PM
Points: 11,638,
Visits: 27,713
the error message is related to debugging.
do you really need to debug the CLR?
why not just deploy the project, then test it in q window for known pattern/values?
Lowell
--
There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1312743
gissah
gissah
Posted Thursday, June 07, 2012 2:14 PM
SSC Rookie
Group: General Forum Members
Last Login: Today @ 4:43 PM
Points: 43,
Visits: 155
do you really need to debug the CLR? No
All I want is to test it.
why not just deploy the project, then test it in q window for known pattern/values?
everything run fine except I don't get any output.
Post #1312777
gissah
gissah
Posted Thursday, June 07, 2012 3:09 PM
SSC Rookie
Group: General Forum Members
Last Login: Today @ 4:43 PM
Points: 43,
Visits: 155
I think I solved my issue, it was from my data it needed some clean up
Post #1312793
Jeff Moden
Jeff Moden
Posted Friday, June 08, 2012 7:17 AM
SSC-Dedicated
Group: General Forum Members
Last Login: Today @ 2:32 PM
Points: 32,906,
Visits: 26,792
Slightly off subject, it's been reported that some forms of Regex CLR are quite slow. If it does turn out to be one of the slow ones, it won't look slow on just a couple of rows but could take quite some time if you're batch processing several thousand rows.
To be sure, I'm not in any way shape or form saying to avoid CLRs. I'm saying the same as I would for any type of code where there was a known issue including T-SQL and to simply be aware of it.
The question that I would have is what are you doing in RegEx that a more simple LIKE or other pattern matching in T-SQL can't do for you? The reason why I'm asking that is because if you are using Regex to replace the simple pattern matching that you can do in T-SQL, there's a very high probability that functionality will be a fair bit slower than the equivalent T-SQL code.
--Jeff Moden
"
RBAR
is pronounced "ree-bar" and is a "Modenism" for "
R
ow-
B
y-
A
gonizing-
R
ow".
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #1313114
« Prev Topic
|
Next Topic »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.