Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

cast vs convert

Posted on 2004-09-27
3
1,013 Views
Last Modified: 2010-08-05
how do i decide which to use: cast() or convert() in t-SQL
0
Comment
Question by:vinny45
  • 2
3 Comments
 
LVL 15

Assisted Solution

by:jdlambert1
jdlambert1 earned 250 total points
ID: 12165196
You didn't find that clearly documented?? Neither did I. :)

I use Cast unless I need the extra "style" argument of Convert, but if you don't need the optional style, it makes no difference in performance or results.
0
 
LVL 34

Accepted Solution

by:
arbert earned 250 total points
ID: 12165249
Straight from books online:

"CAST is based on the SQL-92 standard and is preferred over CONVERT."
0
 
LVL 15

Expert Comment

by:jdlambert1
ID: 12165288
Ah, yes, the old "Look under 'Data Type Conversion' instead of Cast or Convert" trick.  Thanks, Brett!
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Query 34 115
DBF to ... Converter 5 81
multiple application databases same MSSQL instance 5 67
MIcrosoft SQL 2014 Database Copy Question 16 51
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question