Substring and Length function in U SQL

1.8k Views Asked by At

I want all records where ParaName matches with tagName. i have tried Length, LEFT and SUBSTRING function, but i think Length,LEFT and SUBSTRING functions are not possible in U-SQL. If possible, what is the syntax??

@var= 
SELECT * FROM Table
WHERE ParaName LIKE tagName+"%";
2

There are 2 best solutions below

0
On

U-SQL emphasizes the use of C# Expressions and methods on .NET types to handle many common cases that SQL achieves with functions.

In this case your type is string (System.String) so methods like StartsWith() and Contains() can be used among many others.

Example: ParmeterName that begins with tagName

WHERE ParameterName.StartsWith( tagName )

Example: ParmeterName that contains with tagName

WHERE ParameterName.Contains( tagName )
2
On

There are many examples of using various c# expressions and methods at the official reference site - U-SQL Language Reference. Look under the sub-topic Built-in C# Functions and Operators (U-SQL).