This chapter we will discuss about function in sql server so let's check it out:
String Function
1. 'ASCII('[Word]')' -> Return ASCII Code.
Example:ASCII('A')->Result:65
2. 'Char([Word])' -> Return Character.
Example:Char(65)->Result:A
3. 'CharIndex('[Word]','[Sentence]')' ->Return position number word in sentence.
Example:CharIndex('E','HELLO') ->Result:2
4. 'Left([Word],[Number])' ->Taking the word as much a number at left.
Example:Left('HELLO',3)->Result:HEL
5. 'Ltrim([Sentence])' ->Clear space in left at sentence.
Example:Ltrim(' Hello')->Result:Hello
6. 'Right([Word],[Number])' ->Taking the word as much a number at right.
Example:Right('HELLO',3)->Result:LLO
7. 'Rtrim([Sentence])' ->Clear space in right at sentence.
Example:Rtrim('HELLO ')->Result:HELLO
8. 'Len([Sentence])' -> Calculate number of sentence.
Example:Len('HELLO')->Result:5
9. 'Lower([Sentence])' -> Change capital word to lowercase.
Example:Lower('HELLO')->Result:hello
10. 'Reverse(['Sentence'])'->Reverse the Sentence.
Example:Reverse('HELLO')->Result OLLEH
11. 'Upper([Sentence])'->Change lowercase to capital word.
Example:Upper('Hello')->Result:HELLO
12. 'Substring([Sentence],[Start Number],[Number of word])'-> Taking word from start number to number of word.
Example:Substring('Hello Word',2,2)->Result:ll
Date Function
1. 'Getdate()'->Return Complete date.
2. 'datepart(dd,getDate())'->Take a date and month.
3. 'datename(dw,'1980-06-11')'->Return day name at 11 Juny 1980.
4. 'dateadd(yy,2,getdate())'->Add 2 years from system today.
5. 'datediff(dd,'1980-06-11',getdate())'->Calculate the different between day.
Mathematics Function
1. 'abs(-25)'->Return absolute value.
2. 'sin(pi()/2)'->Calculate degree of sinus at 90 desgress.
3. 'exp(1)'->Calculate e power 1.
4. 'radians(180)'->Conversion 180 degress to radian.
5. 'power(2,4)'->Conversion 2 power 4.
6. 'rand(90)'->Rteurn random number under 90.
okay that's is it and finally congratulation you have learn about function in sql server. Thank you for see this tutorial I hope with this tutorial can help you...^^
Saturday, January 29, 2011
Function in SQL Server 2005
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment