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 |
|
PoojaJ
Starting Member
10 Posts |
Posted - 2007-04-13 : 02:27:38
|
| HiJust tried to Run the Following statement in Query AnalyzerSelect convert(varchar(9),convert(integer,1234567890))The Output was an * (asterisk)Can Some one Explain Y??Thanks in advance |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-04-13 : 02:34:58
|
You expected that only the first 9 digits would be converted, right?NO! The answer is readable in Books Online.First I opened Books Online and typed CONVERT in the search box. Then I scrolled down to see what information there is.quote: Truncating and Rounding ResultsWhen you convert character or binary expressions (char, nchar, nvarchar, varchar, binary, or varbinary) to an expression of a different data type, data can be truncated, only partially displayed, or an error is returned because the result is too short to display. Conversions to char, varchar, nchar, nvarchar, binary, and varbinary are truncated, except for the conversions shown in the following table.From data type To data type Result --------------------------------------------------- ------------ ------int, smallint, or tinyint char * varchar * nchar E nvarchar Emoney, smallmoney, numeric, decimal, float, or real char E varchar E nchar E nvarchar E
Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-13 : 03:27:19
|
I expect Error rather than * MadhivananFailing to plan is Planning to fail |
 |
|
|
PoojaJ
Starting Member
10 Posts |
Posted - 2007-04-13 : 03:34:00
|
| Thanks a lot for ur Reply |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-13 : 03:34:44
|
quote: Originally posted by madhivanan I expect Error rather than * MadhivananFailing to plan is Planning to fail
This behavior is by design  KH |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-04-13 : 03:41:38
|
May be bad design MadhivananFailing to plan is Planning to fail |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-04-13 : 04:29:07
|
May be asterisk is chosen because it is commonly used wild-card character which used to represent one or more characters or may be because it resembles shape of bug Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-04-13 : 04:35:02
|
quote: because it resembles shape of bug
This sounds like a more likely reason  KH |
 |
|
|
|
|
|
|
|