Cast Or Convert

Kevin Feasel

2016-11-03

Syntax

Aaron Bertrand discusses the Cast and Convert functions:

Neither is really any more typing than the other, and they both work the exact same way under the covers. So it would seem that the choice between CASTand CONVERT is merely a subjective style preference. If that were always true, however, you probably wouldn’t be reading this post.

There are other cases where you need to use CONVERT in order to output correct data or perform the right comparison. Some examples:

Read on for examples.  My preference is CAST, mostly because it’s fewer characters to type.  But there are certainly advantages to using CONVERT.

Related Posts

Grouping And Aggregating In SQL, R, And Python

Dejan Sarka has a few examples of aggregation in different languages, including SQL, R, and Python: The query calculates the coefficient of variation (defined as the standard deviation divided the mean) for the following groups, in the order as they are listed in the GROUPING SETS clause: Country and education – expression (g.EnglishCountryRegionName, c.EnglishEducation) Country […]

Read More

Docker Commands For DBAs

Marek Masko has some commands which will help DBAs get familiar with Docker: Stop container To stop container: docker stop <container ID> To stop all running containers: docker stop $(docker ps -a -q) Most of the commands are straightforward but it’s nice to have a reference guide.

Read More

Categories

November 2016
MTWTFSS
« Oct Dec »
 123456
78910111213
14151617181920
21222324252627
282930