문제

I have the following SQL Server code which I would like to do in C# code. The logic is - if the pattern '%SELECT %FROM% is found in a string called 'x', then I need to return. The '%' stands for 0 or more characters.

The part I am not getting is how to translate the first line of code into C#?

 IF PATINDEX('%SELECT %FROM%',  @x ) > 0 
  BEGIN
     RETURN;
  END
도움이 되었습니까?

해결책

Take a look at regular expresions for C# and the match function..

The pattern would be something like

.*SELECT .*FROM.*

where .* stands for anything other then a new line.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top