SqlShare.com Logo
 
Skip Navigation Links
Home
Video List
Events
Classes
About Us
Login / Register
Subscribe RSS Feed 

Idera SQL Check

Using CAST to Change Data Types

Converting from one data type to another is a pretty common task for both DBA's and developers. TSQL gives us the CAST function, which allows us to do any conversion that's legal (we can't convert 'Andy' to an int!). We'll show you quite a few different examples and it's worthwhile to spend a few minutes trying it out, especially to see the error you get when you try to do a CAST that fails.

Duration:
4 mins 3 secs
Skill Level:
100
Rating:
4.32 out of 5
Publish Date:
December 06, 2010
Using CAST to Change Data Types You must be logged in to view this video.  
Bookmark and Share
 
1=Poor, 3=Good, 5=Excellent

About the Author

Image of Andy Warren
Andy Warren is a software trainer focusing on SQL Server, a member of the PASS Board of Directors, and a principal in this site - SQLShare.com.

References



Comments
kala devi on 12/9/2010
Very useful to me Thanks

Jamshid Nouri on 12/9/2010
very nice

Todd Burrell on 12/9/2010
Andy, you mentioned error trapping at the end. It would be great to see some examples of how best to implement that.

kk on 12/9/2010
cool!!! Thanks for tis informative session

Derek on 12/9/2010
Cool. I've always seen other programmers code with CAST in Oracle, and I never studied how it was used.

RAJKUMAR on 12/9/2010
NICE VIDEO

Joaquin Ortega on 12/9/2010
What would be diff. between using CAST vs. CONVERT function. Is there any performance advantage? What would be the recomendation?

Nilesh on 12/9/2010
good

D151BB6B9F on 12/9/2010
It got confusing when you cast to datetime and one time it was Dec 30 2010 as a default, but the other default date later in the presentation had 2010 12 03.

Edward on 12/9/2010
This is a very good video. simple and clear xamples on casting datatypes.

FELIX on 12/9/2010
Good video

MartinIsti on 12/9/2010
Nice and easy, though I was missing some intricate tips how to cast strings (or even dates) to different date formats because that's what usually messes up things. Or maybe in another short vid? I would like to have a T-SQL function like Oracles to_date where you can give the masking like yyyy-mm-dd or yyyy/mon/dd. It would be useful. Or there is and only I don't know about it :)

John on 12/9/2010
Aussie dates vs. American dates create confusion with cast unless the YYYY/MM/DD format is used for input string. Perhaps a session on CAST vs. CONVERT for dates would be useful and also SET DATEFORMAT to predefine inputs for CASTing dates

Satyabodhi Densmore on 12/10/2010
Should discuss CONVERT and try-catch here.

ranu on 12/10/2010
gud one

Mat on 12/12/2010
learning to cast will be useful

JohnG on 12/16/2010
These are great! Thanks!

Steve M on 12/22/2010
I don't do a lot of coding, but I often have to modify someone else's code. I have seen CAST in code, but now I understand how to use it.

Worasi on 3/3/2011
Helpful

Frank on 3/18/2011
It was truncated

Maurice Ivory on 6/29/2011
This video didn't work....it timed out after about a minute and a half

Ben on 7/1/2011
This video only plays about a minute and 20 seconds and then it stops is there a way to fix this? Thanks.

Ben on 7/1/2011
This video only plays about a minute and 20 seconds and then it stops is there a way to fix this? Thanks.

Ben on 7/1/2011
This video only plays about a minute and 20 seconds and then it stops is there a way to fix this? Thanks.

Ben on 7/1/2011
This video only plays about a minute and 20 seconds and then it stops is there a way to fix this? Thanks.

Ben on 7/1/2011
This video stops after 1:20 or so and I've made sure I have adobe flash installed and everything anyone have a solution? Thanks.

Jerry Stretch on 7/8/2011
As above - video stops.

chandrasekhar on 9/26/2011
useful video

MohanD on 12/10/2011
Back To Basics



Must Be Logged In
 

How Do I Become a Video Author? |  Newsletter History

Copyright © Fourdeuce, Inc., 2005-2009. All Rights Reserved | Privacy Policy | Terms & Conditions