Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
ZarrinPour
Yak Posting Veteran
66 Posts |
Posted - 2008-09-08 : 13:53:17
|
Hii want to know when i use cast function to convert a numeric data to varchar value, if i don't provide length,what does it mean?Kind Regards.Nothing is quite impossible! |
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-09-08 : 13:58:45
|
get used to checking Books Online - It's a great source.quote: Syntax for CAST:CAST ( expression AS data_type [ (length ) ])length Is an optional parameter of nchar, nvarchar, char, varchar, binary, or varbinary data types. For CONVERT, if length is not specified, the default to 30 characters.
Be One with the OptimizerTG |
|
|
ZarrinPour
Yak Posting Veteran
66 Posts |
Posted - 2008-09-08 : 14:05:09
|
Hi TGquote: Originally posted by TG get used to checking Books Online - It's a great source.[quote]For CONVERT, if length is not specified, the default to 30 characters.
I've already read this in BOL, BUT what about CAST?Kind Regards.Nothing is quite impossible! |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2008-09-08 : 14:12:44
|
I didn't notice the "for CONVERT" but I assume its the same for CAST. This little test seems to confirm it:use tempdbselect cast(0 as varchar) test into #texec sp_help #tOUTPUT:Column_name Type Computed Length ---------------------------------------------------------------------------------------- -------test varchar no 30 Be One with the OptimizerTG |
|
|
ZarrinPour
Yak Posting Veteran
66 Posts |
Posted - 2008-09-08 : 14:21:55
|
Thanks sooo much.Nothing is quite impossible! |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2008-09-08 : 15:16:04
|
Now you've learned the two steps to being a good programmer: If you have a question, first check the documentation. If that doesn't answer it, just write a simple test. - Jeffhttp://weblogs.sqlteam.com/JeffS |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|
|