Open In App

Str() and StrComp() Function in MS Access

1. Str() Function :
In MS Access, the Str() function return a number in the string format. In this function, we can pass any number the function will return that in the string format.

Syntax :



 Str(number) 

Example –

SELECT Str(100) AS ConvertToString;

Output –



ConvertToString
100

Example –

SELECT Str(421) AS ConvertToString;

Output –

ConvertToString
421

2. StrComp() Function :
In MS Access, The StrComp() function compare two strings . It will take two parameter string1, string2 as the parameter. If both strings will be same then it will return 0, and if the first string is greater than second then it will return 1 if string1<string2 then it returns -1 and if string1 or string2 is null then it will return null.

Syntax :

StrComp(string1, string2) 

Example –

SELECT StrComp("geeksforgeeks", "gfg") AS CompString;

Output –

CompString
-1

Example –

SELECT StrComp("gfg", "geeksforgeeks") AS CompString;

Output :

CompString
1
Article Tags :
SQL