Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

What is the general guidance on when you should use CAST versus CONVERT? Are there any performance issues related to choosing one versus the other? Is one closer to ANSI-SQL?

1 Answer

0 votes
by (40.7k points)

CAST is ANSI specific, whereas CONVERT is SQL Server.

CONVERT is more flexible than CAST.  If you are using CONVERT you can format dates and so on. 

Apart from that, they are almost the same. But, if you really don't care about the extended features, then CAST is the right option for you.

Note: Whenever an implicit conversion is used, then you are not supposed to use either CONVERT or CAST.

It’s recommended to use CAST wherever it’s possible.

For more information you can refer to CAST and CONVERT and this graphic as well as SQL Server Data Type Conversion Chart.

Hope this helps you :)

Related questions

0 votes
2 answers
0 votes
1 answer
asked Jul 23, 2019 in SQL by Tech4ever (20.3k points)

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...