Is there any significant difference between these? From BOL quote: Explicitly converts an expression of one data type to another. CAST and CONVERT provide similar functionality.Why do SQL Server have two functions? Is any one of them not supported in earlier versions? Madhivanan Failing to plan is Planning to fail
As stated in BOL they provide same functionality. Both translate a value from one data type to another. Although their performance is also similar, their syntax and potential usage is slightly different. For example, suppose that we want to retrieve order dates from the sales table. However, we don't care about the time portion; all we need to know is the order date. We could use either CAST or CONVERT to do this. Satya SKJ Moderator http://www.SQL-Server-Performance.Com/forum This posting is provided “AS IS†with no rights for the sake of knowledge sharing.
That one is interesting discussion. I prefer to use convert specifically to format the dates and currency data types Madhivanan Failing to plan is Planning to fail
Use CAST whenever you can. This is part of the SQL 92 standard. CONVERT might not be supported in future versions. -- Frank Kalis Microsoft SQL Server MVP http://www.insidesql.de Ich unterstütze PASS Deutschland e.V. http://www.sqlpass.de)
quote:Originally posted by FrankKalis Use CAST whenever you can. This is part of the SQL 92 standard. CONVERT might not be supported in future versions. any reasons for dropping CONVERT in future versions
I guess the only reason might be, that it doesn't conform to the standard. And the standard offers with CAST an almost same functionality. Except for this date formatting. But this is more speculation than anything else. -- Frank Kalis Microsoft SQL Server MVP http://www.insidesql.de Ich unterstütze PASS Deutschland e.V. http://www.sqlpass.de)