CAST vs CONVERT with SQL Server

Greetings all. I’ve read a number of threads on using CAST and CONVERT with a SQL Server database, but I don’t believe I’ve seen the following questions.

Other than the formatting capability provided by the CONVERT function, are there any advantages or disadvantages to using one of these functions over the other? Performance differences? Any instances where you’d specifically choose one of these (aside from formatting)?

I’ve got a numeric column that I need to convert to char. Nothin’ fancy, just unformatted number to unformatted text. Which function to you suggest?

(Used to using Oracle; muddling thru SQL Server.)

Thanks,

Kathy Brown


kbrown :us: (BOB member since 2003-01-20)

Nothing concrete to base this on, but I would expect that cast would be more efficient unless you need the formatting capability of convert. If nothing else its easier to type and shorter and arguably more obvious what it is doing.


ken.gaul :uk: (BOB member since 2002-06-18)

I’ve only really needed to use convert in the past dealing with dates, to make sure that the formatting wasn’t an issue when doing conversions.

Most of the time cast worked fine.


Paul Williams :uk: (BOB member since 2002-07-10)