Friday, February 13, 2015

Convert Functions in SQL Server

9:59 PM - By ajay desai 0

Convert Functions

This function directly converts an expression of one data type to another. It has two conversion functions called CAST and CONVERT which do the same task.

For ex: - select convert(int,10.6496)

select getdate()

select convert(varchar(50),getdate())

Style is an optional parameter which can be used to specify a date format used for converting datetime or smalldatetime data to character. When style is set to null, the result is also null as shown below: -

select convert(varchar(50),getdate(),null)

For ex: - select convert(varchar(50),getdate(),101)

The style values range from 100-114,120,121,126,127,130 and 131 or 0 – 8, 10,11,12 and 14. The default style is 100.

About the Author

I am Azeheruddin Khan having more than 6 year experience in c#, and ms sql.My work comprise of medium and enterprise level projects using and other Microsoft .net technologies. Please feel free to contact me for any queries via posting comments on my blog,i will try to reply as early as possible. Follow me @fresher2programmer
View all posts by admin →

Get Updates

Subscribe to our e-mail newsletter to receive updates.

Share This Post



© 2014 Fresher2Programmer. WP Theme-junkie converted by Bloggertheme9
Powered by Blogger.
back to top