Hi all,

I want to know how to assin a return value to a variable when calling a regex function.
it always returns a bit type of value(its ok). i want that bit type of value tobe cheked whether it is '0' or '1'

this is my C# code in case if u need

namespace SearchBooksLibrary
    public partial class SqlRegularExpressions

        public static int Like(string text, string pattern)
            Match match = Regex.Match(text, pattern);
            if (match.Value != String.Empty)
                return 1;
                return 0;

this is my assembly.

CREATE ASSEMBLY SqlRegularExpressions1 
from 'C:\Users\BJ\Documents\Visual Studio 2008\Projects\Project1\SearchBooksLibrary\SearchBooksLibrary\bin\Debug\SearchBooksLibrary.dll' 

this is my function

CREATE function RegExpLike(@Text nvarchar(max), @Pattern nvarchar(255)) RETURNS bit 
AS EXTERNAL NAME SqlRegularExpressions1.[SearchBooksLibrary.SqlRegularExpressions].[Like]

this is what i want to do which doesnt work

declare @tt nvarchar(max)
set @tt='i love sql but not the other'
declare @ttT nvarchar(max)
set @ttT='(\w*sql\w*)*(server\w*)'
declare @flag bit
@flag=select dbo.RegExpLike(@tt,@ttT )--this line does not work it says Incorrect syntax near '@flag'.

plz help me

Recommended Answers

All 2 Replies


select @flag=dbo.RegExpLike(@tt,@ttT)

thanks it worked

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.