0% found this document useful (0 votes)
16 views

SQL Server

Uploaded by

vishwathirty3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

SQL Server

Uploaded by

vishwathirty3
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

SQL Server

SQL Server
SQL Server is a relational database management system (RDBMS) by
Microsoft. It supports SQL along with additional features known as T-SQL or
Transact-SQL.
Microsoft provides set of tools to manage local or remote SQL Server databases
such as SSMS (SQL Server Management Studio), SQL Server Agent, SQL
Server Analysis Services, SQL Server Reporting Services, SQL Server
Integration Services, etc.

SQL Server Management Studio (SSMS)


SQL Server Management Studio is a free multipurpose integrated tool to access,
develop, administer, and manage SQL Server databases, Azure SQL Databases,
and Azure Synapse Analytics. SSMS allows you to manage SQL Server using a
graphical interface.

SSMS can also be used to access, configure, manage & administer Analysis
services, Reporting services, & Integration services.

Advantages

Its simple and user-friendly syntax allows even non-technical users to interact with
databases and retrieve data without having to write lengthy lines of code. SQL also
provides a standardized way of communicating with databases, ensuring that data
is consistent and uniform across different systems.

SSMS Components
SQL Server Management Studio has the following components:

• Object Explorer
• Security
• Server Objects
• Query and Text Editor
• Template Explorer
• Solution Explorer
• Visual Database Tools

------------------------------------------------

There are two authentication modes in SQL Server using which you can login and
connect with the SQL Server.

• Windows Authentication
• SQL Server Authentication

Windows Authentication
• Windows authentication mode enables local Windows authentication with
SQL Server, where you can login with your local Windows credentials.

Server Authentication
Connecting through SQL Server Authentication. When using SQL Server
Authentication, logins are created in SQL Server that aren't based on
Windows user accounts. Both the user name and the password are created
by using SQL Server and stored in SQL Server.

Advantages of SQL Server Authentication:


• Allows SQL Server to support older applications and applications built on
mixed OS.
• Allows access to web-based applications where users create their own
identities.
• Allows users to connect from unknown domains.

Disadvantages of SQL Server Authentication


• Users using Windows must provide an additional set of login/password to
connect to SQL Server.
• SQL Server authentication cannot use Kerberos security protocol.
• Windows offers additional password policies that are not available for SQL
Server logins.

There are two ways to create a new User or to grant user permissions:

• Using Microsoft SQL Server Management Studio


• Using T-SQL
Create New User using SSMS
Open SQL Server management studio. In the Object Explorer, expand the
Databases node.

Assign Permissions to User in SQL Server


In the previous chapter, you learned to create a new user in the database. Here,
you will learn to grant permissions to a user in SQL Server.

You can GRANT and REVOKE permissions on various database objects in SQL
Server. User permissions are at the database level.

You can grant any or a combination of the following types of permissions:

• Select: Grants user the ability to perform Select operations on the table.
• Insert: Grants user the ability to perform the insert operations on the table.
• Update: Grants user the ability to perform the update operations on the
table.
• Delete: Grants user the ability to perform the delete operations on the table.
• Alter: Grants user permission to alter the table definitions.
• References: References permission is needed to create a Foreign key
constraint on a table. It is also needed to create a Function or View WITH
SCHEMABINDING clause that references that object
• Control: Grants SELECT, INSERT, UPDATE, DELETE, and REFERENCES
permission to the User on the table.

Data Types
• In SQL Server, data type specifies the type of data that can be stored in a
column of a table such as integer data, string data, date & time, binary
strings, etc.
• SQL Server provides built-in data types for all kinds of data that can be
used within SQL Server

Naming Conventions
• SQL Server defines a set of rules (dos and don'ts) for naming SQL Server
Objects called naming convention, but also gives the user to follow their
own preferred style. It is advisable to follow a single naming convention for
all database objects consistently.
Why Use Naming Conventions
• Following a naming convention for tables, columns, and all other related
database objects like views, stored procedures, indexes, triggers, etc., are
important for the success and maintenance of a project. A database can
have many tables and users working on it. By following a naming
convention, you can spend less time finding what you need and helps in
efficient database management.

Database Object Naming Rules


• SQL Server object names should adhere to naming conventions, beginning with an alphabet or
underscore, avoiding special characters, and employing meaningful English words for clarity
and consistency.
• Tables should represent real-world entities, named with descriptive nouns, avoiding prefixes
like 'tbl_', and utilizing camel case or underscores for multi-word names, ensuring they are less
than 126 characters.

Create Database
• In SQL Server, a database is made up of a collection of objects like tables,
functions, stored procedures, views etc. Each instance of SQL Server can
have one or more databases.
• SQL Server databases are stored in the file system as files. A login is used
to gain access to a SQL Server instance and a database user is used to
access a database. SQL Server Management Studio is widely used to work
with a SQL Server database.

Type of Database in SQL Server


There are two types of databases in SQL Server: System Database and User
Database.

System databases are created automatically when SQL Server is installed.

• master: master database stores all system level information for an instance
of SQL Server. It includes instance-wide metadata such as logon accounts,
endpoints, linked servers, and system configuration settings.
• model: model database is used as a template for all databases created on the
instance of SQL Server
• msdb: msdb database is used by SQL Server Agent for scheduling alerts and
jobs and by other features such as SQL Server Management Studio, Service
Broker and Database Mail.
• tempdb: tempdb database is used to hold temporary objects, intermediate
result sets, and internal objects that the database engine creates.

User-defined Databases are created by the database user using T-SQL or


SSMS for your application data. A maximum of 32767 databases can be created
in an SQL Server instance.

Create New Table in SQL Server


Tables are database objects that contain all the data in a database. In a table,
data is logically organized in rows and columns. Each column represents a field
and each row represents a unique record. Each column has a data type associated
with it. It represents the type of data in that column. Each table is uniquely named
in a database.

Number of tables in a database is only limited by the number of objects allowed


in the database (2,147,483,647). A user-defined table can have up to 1024
columns.

There are two ways to create a new table in SQL Server:

• Using T-SQL Script


• Using Table Designer in SQL Server Management Studio

ALTER TABLE ADD Columns in a Table


• You can add columns to an existing table by using the ALTER TABLE
statement.
• ALTER TABLE statement can also be used to rename or delete columns in
an existing table
• Use the ALTER TABLE ADD statement to add one or more columns to an existing
table.
• Syntax:
ALTER TABLE [schema_name.]table_name
ADD column_name1 data_type constraint,
column_name2 data_type constraint ...
column_nameN data_type constraint;
ALTER TABLE dbo.Employee
Add Address varchar(500) NOT NULL;

Identity Column
In SQL Server, a column in a table can be set as an identity column. It is used
for generating key values for primary key columns.

Use the IDENTITY[(seed, increment)] property with the column to declare it as an


identity column in the CREATE TABLE or ALTER TABLE statements.

Syntax:
column_name data_type IDENTITY[(seed, increment)]
Parameters:
1. Seed is the first value of the identity column.
2. Increment is the incremental value added to the identity value of the previous
row.

RENAME Column or Table Name


You can rename table name, column name of an existing table, index name
by using the system stored procedure sp_rename.

Syntax:
EXEC sp_rename 'old_name', 'new_name' [, 'object_type'];

Delete Columns of a Table


Use ALTER TABLE DROP COLUMN statement to delete one or more columns of a table using
T-SQL.

Syntax:
ALTER TABLE [schema_name.]table_name
DROP column column_name1, column_name2,... column_nameN;

The following deletes the Address column of the Employee table.

ALTER TABLE dbo.Employee


DROP COLUMN Address;

Database Schema
In SQL Server, a schema is a logical collection of database objects such as tables,
views, stored procedures, indexes, triggers, functions. It can be thought of as a
container, created by a database user. The database user who creates a schema
is the schema owner.
• A schema can belong to only one database whereas a database can have one
or multiple schemas.
• There are no restrictions on the number of objects in a schema.
• SQL Server provides us with a few built-in schemas such as dbo, guest, sys,
etc.
• A database schema can be owned by a database role or an application role
along with the database user. They are called schema owners.
• dbo is the default schema for a newly created database.
• Schema ownership can be transferred from one user to another user in the
same database.
• A database user can be dropped without dropping the database objects owned
by the user. But the schema cannot be deleted if it owns database objects.

Tables Relations
It is important to understand and design relationships among tables in a relational
database like SQL Server. In a relational database, each table is connected to
another table using the Primary-Foreign Key constraints.

Table relationships in SQL Server database are of three types:

1. One-to-One
2. One-to-Many
3. Many-to-Many

The following query will display data from all the tables.

4. SELECT * FROM Employee


5. SELECT * FROM EmployeeSkill
6. SELECT * FROM SkillDescription

Primary Key
Here you will learn what is a primary key and how to create it in a new or existing
table in the SQL Server database.

What is Primary Key?


In SQL Server, a Primary key is a constraint that uniquely identify each row in
the table. It enforce data integrity in tables.

• A table can have only one primary key.


• A primary key can be defined on one column or the combination of multiple
columns known as a composite primary key.
• A primary key cannot exceed 16 columns and a total key length of 900 bytes.
• The primary key uniquely identifies each row in a table. It is often defined on
the identity column.
• The Primary key column do not allow NULL or duplicate values. It will raise
an error if try to do so.
• All columns defined within the primary key constraint must be defined as a
NOT NULL column.
• If clustered or nonclustered is not specified, then a unique clustered index for
the primary key column will be created if there no clustered index on the
table. This makes retrieving data faster whenever the primary key column is
included in the query.

Delete a Primary Key

ALTER TABLE Employee


DROP CONSTRAINT PK_Employee_EmployeeID;

What is Foreign Key?


The foreign key establishes the relationship between the two tables and enforces
referential integrity in the SQL Server. For example, the following Employee table
has a foreign key column DepartmentID that links to a primary key column of
the Department table.

• A foreign key column can be linked to a primary key or a unique key column
of the same or another table.
• Foreign key constraints can reference tables within the same database in the
same server.
• Foreign key constraints can be defined to reference another column in the
same table. This is referred to as a self-reference.

It is used to create relationships between two tables by associating rows of


one table with that of another.
Delete a Foreign Key using T-SQLUse the ALTER TABLE DROP
CONSTRAINT command to delete a foreign key constraint in an existing
table.

Check Constraints
In SQL Server, a check constraint is used to specify the limitation on the values
of a column when inserting or updating.
Unique Key Constraints
The Unique Constraint ensures the uniqueness of all values and no duplicate
values are entered in a column of a table.

Views
In SQL Server, a view is a virtual table whose values are defined by a query. In
another word, a view is a name given to a query that can be used as a table. The
rows and columns of a view come from tables referenced by a query.

Important Points
• Unless indexed, a view does not exist as a stored set of data values in a
database.
• Views can be created by using tables or other views in the current or other
databases.
• The SQL statements comprising the view are stored in the database and not
the resulting data.
• The data from a view is generated dynamically when a view is referenced.

Functions
• Functions in SQL Server are similar to functions in other programming
languages. Functions in SQL Server contains SQL statements that perform
some specific tasks. Functions can have input parameters and must return
a single value or multiple records.

Types of Functions
SQL Server Functions are of two types:

System Functions: These are built-in functions available in every database.


Some common types are Aggregate functions, Analytic functions, Ranking
functions, Rowset functions, Scalar functions.

User Defined Functions (UDFs): Functions created by the database user are
called User-defined functions. UDFs are of two types:
1. Scalar functions: The function that returns a single data value is called a scalar
function.
2. Table-valued functions: The function that returns multiple records as a table
data type is called a Table-valued function. It can be a result set of a single
select statement.

Advantage of User-defined Functions


• Faster Execution: Similar to stored procedures, UDFs reduce the compilation
cost of T-SQL by caching the plans and reusing them for future executions.
• Reduce Network Traffic: The SQL statements of a function execute in the
database, and the application calling it needs to make a function call to the
database.
• Supports Modular Programming: UDFs can be modified independently of the
application source code

Stored Procedures
A stored procedure is a group of SQL statements that are created and stored in a
database management system, allowing multiple users and programs to share and
reuse the procedure. A stored procedure can accept input parameters, perform the
defined operations, and return multiple output values.

the main use of stored procedure?


Security: Stored procedures allow you to enhance the security of an
application or a database by restricting the users from direct access to the
table. Low network traffic: The server only passes the procedure name
instead of the whole query, reducing network traffic.

Stored procedures are of two types:

User-defined procedures: A User-defined stored procedure is created by a


database user in a user-defined database or any System database except the
resource database.

System procedures: System procedures are included with SQL Server and are
physically stored in the internal, hidden Resource database and logically appear
in the sys schema of all the databases. The system stored procedures start with
the sp_ prefix.
Advantages of Stored procedures
• Stored procedures are reusable. Multiple users in multiple applications can
use the same Stored Procedure (SP)
• As SPs reside in the database, it reduces network traffic. Applications have to
make a procedure call to the database and it communicates back to the user.
• Database objects are encapsulated within a stored procedure, and this acts
as a security mechanism by restricting access to the database objects.
• Reduced development cost, easily modified, and increased readability.
• Improves performance. When a stored procedure is executed for the first
time, the database processor creates an execution plan which is re-used every
time this SP is executed

Stored Procedure Parameters: Input, Output,


Optional
Here you will learn about stored procedure parameters, optional parameters, and
executing stored procedures with parameters in SQL Server.

• A stored procedure can have zero or more INPUT and OUTPUT parameters.
• A stored procedure can have a maximum of 2100 parameters specified.
• Each parameter is assigned a name, a data type, and direction like Input,
Output, or Return. If a direction is not specified, then by default, it is Input.
• You can specify a default value for the parameters.
• Stored procedures can return a value to the calling program if the parameter
is specified as OUTPUT.
• The parameter values must be a constant or a variable. It cannot be a function
name.
• Parameter variables can be either user-defined or system variables like @spid

Parameter Names
• The stored procedure parameters names must start with a single @.
• The name must be unique in the scope of the stored procedure.
• If parameter values are passed as @Param1 = value1, @ Param2 = value2
as shown in the above example, then the parameters can be passed in any
order.

OUTPUT Parameters
• The OUTPUT parameter is used when you want to return some value from
the stored procedure. The calling program must also use the OUTPUT
keyword while executing the procedure.

Optional Parameters
• SQL Server allows you to specify the default values for parameters. It allows
you to skip the parameters that have default values when calling a stored
procedure.

Indexes: Clustered Indexes


An Index in SQL Server is a data structure associated with tables and views that
helps in faster retrieval of rows.

Data in a table is stored in rows in an unordered structure called Heap. If you


have to fetch data from a table, the query optimizer has to scan the entire table
to retrieve the required row(s). If a table has a large number of rows, then SQL
Server will take a long time to retrieve the required rows. So, to speed up data
retrieval, SQL Server has a special data structure called indexes.

An index is mostly created on one or more columns which are commonly used in
the SELECT clause or WHERE clause.

There are two types of indexes in SQL Server:

1. Clustered Indexes
2. Non-Clustered Indexes

Clustered Indexes
3. The clustered index defines the order in which the table data will be sorted
and stored. As mentioned before, a table without indexes will be stored in
an unordered structure. When you define a clustered index on a column, it
will sort data based on that column values and store it. Thus, it helps in
faster retrieval of the data.
4. There can be only one clustered index on a table because the data rows can
be stored in only one order.
5. When you create a Primary Key constraint on a table, a unique clustered
index is automatically created on the table.

Non-Clustered Indexes
SQL Server provides two types of indexes, clustered and non-clustered
indexes. Here you will learn non-clustered indexes.
The non-clustered index does not sort the data rows physically. It creates a
separate key-value structure from the table data where the key contains
the column values (on which a non-clustered index is declared) and each
value contains a pointer to the data row that contains the actual value.

Modify Index
To add, remove, or change the position of an index column, you must drop and
recreate the index. However, you can set several options on the index using
ALTER INDEX statement.

Triggers in SQL Server


The trigger is a database object similar to a stored procedure that is executed
automatically when an event occurs in a database. There are different kinds of
events that can activate a trigger like inserting or deleting rows in a table, a user
logging into a database server instance, an update to a table column, a table is
created, altered, or dropped, etc.

There are three types of triggers in SQL Server

• DML triggers are automatically fired when an INSERT, UPDATE or DELETE


event occurs on a table.
• DDL triggers are automatically invoked when a CREATE, ALTER, or DROP
event occurs in a database. It is fired in response to a server scoped or
database scoped event.
• Logon trigger is invoked when a LOGON event is raised when a user session
is established.

Sequence in SQL Server


In SQL Server, the sequence is a schema-bound object that generates a sequence
of numbers either in ascending or descending order in a defined interval. It can
be configured to restart when the numbers get exhausted.

• A Sequence is not associated with any table.


• You can refer a sequence to generate values with specific increment and
interval on each execution by using NEXT VALUE FOR. You don't need to insert a
row in a table (like identity column) to generate the sequence.
Synonyms in SQL Server
• In SQL Server, the synonym is the database object that provides alternate
name (alias) to another database objects such as table, view, stored
procedure, etc. in the local server or a remote server. It provides a layer of
abstraction and protects the client application in case of a name change or
location change made to the base object.

Create Synonym
A few points to consider while creating a synonym:

• A synonym must have a unique name just like other database objects in a
schema.
• A synonym cannot be a base object for another synonym.
• A synonym cannot reference a user -defined aggregate function.

IF ELSE Statement in SQL Server


The IF ELSE statement controls the flow of execution in SQL Server. It can
be used in stored-procedures, functions, triggers, etc. to execute the SQL
statements based on the specified conditions.

Loops in SQL Server


In SQL Server, a loop is the technique where a set of SQL statements are
executed repeatedly until a condition is met.

SQL Server supports the WHILE loop. The execution of the statements can be
controlled from within the WHLE block using BREAK and CONTINUE keywords.

----------------------------------- * -------------------------------------------

Insert Data into Tables in SQL Server using


INSERT Statement
The INSERT INTO statement is used to insert single or multiple records into a
table in the SQL Server database.

Syntax:
INSERT INTO table_name(column_name1, column_name2...)

VALUES(column1_value, column2_value...);

Update data in a Table using UPDATE Statement


SQL Server supports the standard SQL to update the data in the table. Use the
UPDATE TABLE statement to update records in the table in SQL Server.

Syntax:
UPDATE table_name

SET column_name1 = new_value,

column_name2 = new_value,

...

[WHERE Condition];

Note that the WHERE clause is optional, but you should use it to update the
specific record.

Delete Data using DELETE Statement


Use the DELETE statement to delete data from the existing table in the current
schema or tables of the schema on which you have the DELETE privilege.

Syntax:
DELETE FROM table_name [WHERE Condition];

SQL Server - SELECT Statement


In SQL Server, the SELECT statement is used to retrieve rows/columns data from
one or more existing tables. It follows the SQL (Structured Query Language)
standards.
SELECT column1, column2,...columnN

FROM table_name

Advantage of Alias:

• Alias makes a column more readable in the result set.


• Alias is used to give a small, abbreviated, and meaningful name to tables in
the query so that it will be easy to refer tables in joining multiple tables.
• Alias helps us to identify which column belongs to which table in case of
getting data from multiple tables.

WHERE Clause
In SQL Server, the SELECT statement can have an optional WHERE clause to filter
the data. The WHERE clause can include one or more boolean conditions to filter
out data of the tables.

The WHERE clause always comes after the FROM clause and before GROUP BY,
HAVING, and ORDER BY clauses.

GROUP BY Clause
In SQL Server, the GROUP BY clause is used to get the summary data based on
one or more groups. The groups can be formed on one or more columns. For
example, the GROUP BY query will be used to count the number of employees in
each department, or to get the department wise total salaries.

You must use the aggregate functions such as COUNT(), MAX(), MIN(), SUM(), AVG(),
etc., in the SELECT query. The result of the GROUP BY clause returns a single
row for each value of the GROUP BY column.

Syntax:
SELECT column1, column2,...columnN FROM table_name

[WHERE]

[GROUP BY column1, column2...columnN]


[HAVING]

[ORDER BY]

HAVING Clause
In SQL Server, the HAVING clause includes one or more conditions that should
be TRUE for groups of records. It is like the WHERE clause of the GROUP BY
clause. The only difference is that the WHERE clause cannot be used with
aggregate functions, whereas the HAVING clause can use aggregate functions.

The HAVING clause always comes after the GROUP BY clause and before the
ORDER BY clause.

Syntax:
SELECT column1, column2,...columnN

FROM table_name

[WHERE]

[GROUP BY column1, column2...columnN]

[HAVING conditions]

[ORDER BY]

ORDER BY Clause
In SQL Server, the ORDER BY clause is used in the SELECT query to sort the
result in ascending or descending order of one or more columns.

Syntax:
SELECT column1, column2,...columnN

FROM table_name

[WHERE]
[GROUP BY]

[HAVING]

[ORDER BY column(s) [ASC|DESC]]

ORDER BY Characteristics:

• The ORDER BY clause is used to get the sorted records on one or more
columns in ascending or descending order.
• The ORDER BY clause must come after the WHERE, GROUP BY, and HAVING
clause if present in the query.
• Use ASC or DESC to specify the sorting order after the column name. Use
ASC to sort the records in ascending order or use DESC for descending order.
By default, the ORDER BY clause sort the records in ascending order if the
order is not specified.

INNER JOIN Query


The INNER JOIN query is used to retrieve the matching records from two or more
tables based on the specified condition. SQL Server follows the SQL stadards for
inner join queries.

Syntax:
SELECT table1.column_name(s), table2.column_name(s)

FROM table1

INNER JOIN table2

ON table1.column_name = table2.column_name;

LEFT JOIN Query


The LEFT JOIN is a type of inner join where it returns all the records from the left
table and matching records from the right table. Here, the left table is a table
that comes to the left side or before the "LEFT JOIN" phrase in the query, and
the right table refers to a table that comes at the right side or after the "LEFT
JOIN" phrase. It returns NULL for all non-matching records from the right table.
In some databases, it is called LEFT OUTER JOIN.

RIGHT JOIN Query


The RIGHT JOIN is the reverse of LEFT JOIN. The RIGHT JOIN query returns all
the records from the right table and matching records from the left table.

Here, the right side table is a table that comes to the right side or after the
"RIGHT JOIN" phrase in the query, and the left table is a table that comes at the
left side or before the "RIGHT JOIN" phrase.

The RIGHT JOIN returns NULL for all non-matching records from the left table. In
some databases, it is called RIGHT OUTER JOIN.

FULL JOIN Query


The FULL JOIN returns all the records all the specified tables. It includes NULL for
any non-matching records.

In some databases, FULL JOIN is called FULL OUTER JOIN. It can return a very
large result set because it returns all the rows from all the tables.

Self-Join in SQL Server


In SQL Server, the self-join is like a regular join, but it joins a table to itself.
Similar to any other join, a self-join requires at least two tables. But instead of
adding a different table to the join, you add another instance of the same table.
It is a join between two copies of the same table. Self-join is mainly used for
querying the hierarchical data stored in a single table.

There is no Self Join keyword. You write a normal join where both the tables
involved in the join are the same.

The following is the syntax of the self-join query.

Syntax: Self-join

Copy
SELECT a.column1, b.column2
FROM table1 a, table1 b
WHERE condition;
Dynamic SQL in SQL Server
Dynamic SQL is a programming technique where you build SQL query as a string
and execute it dynamically at runtime. It lets you build the general-purpose query
on the fly using variables, based on the requirements of the application. This
makes a dynamic SQL more flexible as it is not hardcoded.

For example, the following is a dynamic SQL.

Example: Dynamic SQL

Copy
DECLARE @sql nvarchar(max) --declare variable
DECLARE @empId nvarchar(max) --declare variable for parameter

set @empId = '5' --assign value to parameter variable


set @sql = 'SELECT * FROM EMPLOYEE WHERE EMPID =' + @empId --build query
string with parameter

exec(@sql) --execute sql query

Built-in Functions
The following is the list of built-in String functions, DateTime functions, Numeric
functions and conversion functions.

CHAR Returns a character for an ASCII value.


CONCAT Concatenates two or more string values in an end to end manner and returns a single
UPPER Converts a lowercase string to uppercase.
LOWER Converts a string to lower case.
CURRENT_TIMESTAMP Returns the current system date and time of the computer on which the SQL server
installed. Time zone is not included.
DATEADD Returns a new datetime value by adding an interval to the specified datepart of the sp
AVG Returns the average value of an expression/column values.
COUNT Returns the number of records in the SELECT query.
MAX Returns the maximum value in an expression.
MIN Returns the minimum value in an expression.
RAND Returns a random floating point value using an optional seed value.
ROUND Returns a numeric expression rounded to a specified number of places right of the dec
CONVERT Converts and formats a value of one data type to another data type.
USER_NAME Returns the current logged-in user name.

You might also like