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

TSQL Functions

The document provides a comprehensive overview of various T-SQL functions categorized into numeric, string, date, system, and aggregate functions. It includes examples of each function type, demonstrating their usage in SQL queries. The examples cover operations such as mathematical calculations, string manipulations, date retrieval, and database information queries.

Uploaded by

SHAHIDHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

TSQL Functions

The document provides a comprehensive overview of various T-SQL functions categorized into numeric, string, date, system, and aggregate functions. It includes examples of each function type, demonstrating their usage in SQL queries. The examples cover operations such as mathematical calculations, string manipulations, date retrieval, and database information queries.

Uploaded by

SHAHIDHA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

'''T-SQL Functions'''

'''Numeric Functions'''
select abs(34.5);
select sin(90);
select cos(90);
select tan(90);
select exp(4);
select log(10);
select pi();
select sign(-2);
select sqrt(4);
select rand();
select ceiling(34.78);
select floor(34.78);
select degrees(90);
select radians(90);
select round(34.45566,1);

'''String Functions'''

Select ASCII('CSC');
Select CHAR(67);
select len('text');
select lower('SHAHIDHA');
select UPPER('shahidha');
select ltrim(' shahidha');
select rtrim('shahidha ');
select reverse('shahidha');
select replicate('shahidha',2);
select left('shahidha',3);
select right('shahidha',3);
select space(100);
select str(13.5);
select stuff('Shhaidha',2,4,'Begum');
'''Date Functions'''
select getdate();
select getdate()+5;
select day('3/3/2022');
select month('3/3/2022');
select year('3/3/2022');

'''System Functions'''
select db_name();
select db_id('sultan');
select host_name();
select datalength('shahidha');
select object_id('sultan');
select object_name('sultan');
select suser_id('sa');
select user_id(1);
select suser_name(1);

'''Aggregate Functions'''
use kabeer;
select * from student;
select avg(mark) from student;
select sum(mark) from student;
select count(mark) from student;
select count(*) from student;
select min(mark) from student;
select max(mark) from student;

You might also like