..
A string, in computing, is a set of alphanumeric characters. It can be such a name, address, telephone number, or many other types of data. It is therefore a very flexible type of data store through which the widest variety of information.
This type of data, of course, is widely used in databases. Just to emphasize the importance of this type of data, we note that one of the most popular database management software (DBMS, DataBase Management System) that Microsoft SQL Server supplies a set of functions specifically dedicated to treat string data ( also known as variable-length character sets, or varchar):
We use the LEN function to know the length of the string passed as a parameter, including spaces. Thus, for example, running:
SELECT LEN ('test string')
results in 16.
The functions LOWER and UPPER
We can use the LOWER and UPPER functions for the management of capital and lowercase letters. Both take a string as the only input parameter.
The LOWER function returns a string equal to the past, but in which the letters are replaced by the corresponding lower case, while the UPPER function performs the reverse process, transforming the tiny capital letters. Thus, for example, by performing the following functions:
SELECT LOWER ('test string')
SELECT UPPER ('test string')
the results are, respectively:
'String test' 'TEST STRING'LTRIM and RTRIM functions
LTRIM and RTRIM functions are meant to trim the beginning (LTRIM) or end (RTRIM) of the string passed as a parameter. Imagine in this way to declare a variable of type varchar doc:
DECLARE @ doc varchar (64) SELECT @ doc = 'phrase with spaces'Let us apply the LTRIM and RTRIM functions to the variable DOC:
SELECT LTRIM (@ doc) SELECT RTRIM (@ doc)The results are:
'Phrase with spaces' 'Phrase with spaces'
| |
MS Access (Advanced)
Learn how to create and manage databases quickly and easily. Starting from 29 €. |
| |
MySQL (Course)
Management of open-source database. From 39 €. |
| |
SQL and Database (Course)
Create and manage relational databases. From 39 €. |