CONVERSION FUNCTIONS :-
This functions is used to one type to another type.
Cast ( ) Function in SQL Server with Examples:-
Syntax :- cast (expr as type)
Example :- Select ename+earns+ cast(sal as varchar) from emp
Output :-
- Smith earns 2000
- Anu earns 4000
Example :-
Select ename+joined on +cast(hiredate as varchar) from emp.
Select ename+joined on + Date name (dw,hiredate) from emp.
Convert ( ) Function in SQL Server with Examples:-
Syntax : Convert(targettype,source value)
Example :-
- Select convert (int,10.2345)
- ↓
- Output →10
- Select convert(varchar,getdate())
- ↓
- Output→ OCT, 24, 2009