Sql Server System define function

System function are those functions which is pre-defined and  perform operations and return information about database objects in SQL Server
below are some system function
Count, Avg,Min, Max etc.

What would be the output of below queries.

SELECT 'A'+'B'
Output : AB

SELECT 'A'+1
Output :Conversion failed when converting the varchar value 'A' to data type int.

SELECT '1'+'A'
Output : 1A

SELECT 16
Output : 16

SELECT $
Output :0.00

SELECT COUNT(*)
output : 1

SELECT COUNT('8')
output: 1

SELECT (SELECT 'DAL CHAND')
output : DAL CHAND

SELECT SELECT 'DAL CHAND'
output: Incorrect syntax near the keyword 'SELECT'.

SELECT * FROM 'Employees'
output: Incorrect syntax near 'Employees'.

SELECT COUNT(*) + COUNT(*)
output: 2

SELECT 'DAL CHAND' FROM Employees
output: it will print the DAL CHAND total number of rows times.
so here we have 2 records in employees table so name will print 2 times
DAL CHAND
DAL CHAND

SELECT SUM(1+4*3)
output: 13

SELECT MAX(1,3,4)
output: The MAX function requires 1 argument(s).

SELECT MAX('DAL CHAND')
output: DAL CHAND

Select Count(SELECT id FROM Employees)
output:Incorrect syntax near the keyword 'SELECT'.
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ')'.

SELECT 1 + '1'
output: 2

SELECT '1' + 1 
output: 2

SELECT NULL + 5
output: NULL

SELECT NULL + '1'
output: NULL

SELECT 1 WHERE NULL = NULL
output: (0 row(s) affected)

SELECT SUM('1')
output: Operand data type varchar is invalid for sum operator.

SELECT SUM(NULL)
output: Operand data type void type is invalid for sum operator.

SELECT 6/0
output:Divide by zero error encountered.

SELECT 0/0
output:Divide by zero error encountered.

SELECT 0/9
output:0

No comments:

Post a Comment