Saturday, December 18, 2010

SQL functions

SELECT ASCII('123')--GET THE ASCII CORRESPONDANCE OF THE GIVEN STRING
SELECT MAX(CAST(number AS BIGINT)) FROM spt_values 
SELECT MIN(CAST(number AS BIGINT)) FROM spt_values 
SELECT AVG(CAST(number AS BIGINT)) FROM spt_values 
SELECT SUM(CAST(number AS BIGINT)) FROM spt_values 
SELECT CEILING(3.8)
SELECT FLOOR(3.8)
SELECT ROUND(3.84554,2)
SELECT CHAR(65)--GET THE CHARECTER CORRESPONDANCE OF THE ASCII CHAR
SELECT CHARINDEX('E','KALETH') --DEFAULT FIRST OCCURENCE
SELECT CHARINDEX('E','EELETH',3)  --FIRST OCCURENCE AFTER THE  LOCATION MENTIONED
SELECT COUNT(number) FROM spt_values 
SELECT GETDATE()
SELECT DATEADD(DD,5,GETDATE())
SELECT DATEDIFF(DD,GETDATE(),DATEADD(DD,5,GETDATE()))
SELECT DAY(GETDATE())
SELECT MONTH(GETDATE())
SELECT YEAR(GETDATE())
SELECT ISNULL(NULL,2)
SELECT LEFT('HAI',2)--'HA'
SELECT RIGHT('HAI',2)--'AI'
SELECT LEN(' KALETH')--7
SELECT LOWER('KaLETH')
SELECT UPPER('KaLETH')
SELECT LEN(LTRIM(' KaLETH  '))
SELECT LEN(RTRIM('   KaLETH '))
SELECT PATINDEX('%XX%','JXFDxxJDSKXXAJ')
SELECT REPLACE('KAA  LETH',' ','ME')--KAAMEMELETH
SELECT REPLICATE('KALETH',2)--KALETHKALETH
SELECT SOUNDEX('KALETH')--A430
SELECT SPACE(50)+'KALETH' +SPACE(50) +'B'
SELECT STUFF('KALETH',5,1,'ALI')
SELECT SUBSTRING('KALETH',1,5)
SELECT ABS(10)
SELECT ACOS(0.9)
SELECT ASIN(0.1)
SELECT ATAN(0.9)
SELECT COS(0.9)
SELECT SIN(0.1)
SELECT TAN(0.9)
SELECT ATN2(1,1)
SELECT CONVERT(VARCHAR(50),GETDATE(),100) as  a_100
SELECT CONVERT(VARCHAR(50),GETDATE(),101) as  a_101
SELECT CONVERT(VARCHAR(50),GETDATE(),102) as  a_102
SELECT CONVERT(VARCHAR(50),GETDATE(),103) as  a_103
SELECT CONVERT(VARCHAR(50),GETDATE(),104) as  a_104
SELECT CONVERT(VARCHAR(50),GETDATE(),105) as  a_105
SELECT CONVERT(VARCHAR(50),GETDATE(),106) as  a_106
SELECT CONVERT(VARCHAR(50),GETDATE(),107) as  a_107
SELECT CONVERT(VARCHAR(50),GETDATE(),108) as  a_108
SELECT CONVERT(VARCHAR(50),GETDATE(),109) as  a_109
SELECT CONVERT(VARCHAR(50),GETDATE(),110) as  a_110
SELECT CONVERT(VARCHAR(50),GETDATE(),111) as  a_111
SELECT EXP(0)
SELECT LOG(2)
SELECT LOG10(10)
SELECT POWER(2,3)
SELECT SIGN(-134540)
SELECT SIGN(34540)
SELECT SQRT(4)
SELECT @@ROWCOUNT
SELECT @@ERROR

No comments:

Post a Comment