SQL SERVER – DIFFERENCE BETWEEN CAST AND CONVERT(Cast vs Convert)

Both cast and covert serves the same purpose i.e. convert a data type to another.

  • Cast
  1. Cast is  ANSII Standard
  2. Cast cannot be used for Formatting Purposes.
  3. Cast cannot convert a datetime to specific format
  • Convert
  1. Convert is Specific to SQL SERVER
  2. Convert can be used for Formatting Purposes.For example Select convert (varchar, datetime, 101)
  3. Convert can be used to convert a datetime to specific format
print

6 thoughts on “SQL SERVER – DIFFERENCE BETWEEN CAST AND CONVERT(Cast vs Convert)

  1. Author’s gravatar

    Sir ,thanks for your information on your website..Please i want to ask one question about how to store multiple languages like english,hindi and kannada in sql server database…

    1. Author’s gravatar

      Use nvarchar…….

      All the best

      Reply
  2. Author’s gravatar

    WOW WONDERFUL>>>>>>>>>>>>……………

  3. Author’s gravatar

    When you cast a number to real of size -1.18E-39 you expect an conversion error, so removing a zero should be OK. You have to remove zero’s until -1.18E-36 before the error is not thrown.
    Using convert you can use up to -1.18E-38 before the number is changed into a 0 (zero)

  4. Author’s gravatar

    LOLOLOLOLOL

  5. […] SQL SERVER – DIFFERENCE BETWEEN … – Both cast and covert serves the same purpose i.e. convert a data type to another.# Convert is Specific to SQL SERVER.Convert can be used for Formatting […]

Leave a Reply

Your email address will not be published. Required fields are marked *


+ two = 10