| Author |
Topic |
|
ramana123
Yak Posting Veteran
57 Posts |
Posted - 2005-07-28 : 01:41:18
|
| hi all,i faced one problem..insqlserver i have one SP.this will take parameters types as follows..varchar,int,varchariam passing mistkely as (11,null,null)instead of ('11',null,null)my procedure executed successsfull and gives correct out put..really iam amazing is it possible in sqlserver????pls help me out.. |
|
|
Merkin
Funky Drop Bear Fearing SQL Dude!
4970 Posts |
Posted - 2005-07-28 : 01:44:59
|
really you are amazing ?If you want to convert... look up convert in books online, lots of good info.Really amazing even Damian"A foolish consistency is the hobgoblin of little minds." - Emerson |
 |
|
|
ramana123
Yak Posting Veteran
57 Posts |
Posted - 2005-07-28 : 01:50:33
|
| hi merkin,i know we can convert using convert function..but with out this automatically convertoion is possible in sqlserver???? |
 |
|
|
timmy
Master Smack Fu Yak Hacker
1242 Posts |
Posted - 2005-07-28 : 02:08:34
|
| There are certain things that SQL Server will convert implicitly, and this is one of them. As Damian said, the list of these permutations are in BOL if you look up CAST or CONVERT. But, to be on the safe side, it's always best for you to supply the param in the format required. It saves problems later on...HTH,Tim |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-07-28 : 02:09:42
|
| As long as the data is only numeric then it will be considered as string by default if inserted to a varchar field. if you enter 11a you will get error. In that case you need to insert it as '11a'MadhivananFailing to plan is Planning to fail |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-07-28 : 02:11:51
|
| SQL makes lots of implicit conversions. Passing 1ABC2 to your Sproc, instead of '1ABC2' will result in error. OTOH our ASP application puts quotes around all parameters before passing them to SQL (i.e. dynamic SQL type calls) - regardless of whether they are supposed to be numbers, or not, and SQL is quite happy.MONEY is the only type which is badly endowed for implicit conversions IME.You can also happily do sp_helptext MySProcNameinstead ofsp_helptext 'MySProcName'and so on.Kristen |
 |
|
|
ramana123
Yak Posting Veteran
57 Posts |
Posted - 2005-07-28 : 02:22:05
|
| ok thakns for all my problem was realyy cleared..thanks alot..!!! |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-07-28 : 02:44:43
|
| "if you enter 11a you will get error"Its worth thinking about how you pass the parameters because, for example, if you pass 1e instead of '1e' SQL will happily consider it to be a number - whereas SQL will not implicitly convert '1e' to a number, but it will implicitly convert '1' to an intKristen |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2005-07-28 : 03:11:54
|
| yes thats true. 11e1 will be considered as 110But isnumeric('11e1') will return 1MadhivananFailing to plan is Planning to fail |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-07-28 : 06:53:50
|
Well 1e is pretty rough to be treated as a number IMHO. As is IsNumeric not recognising it, or even '11e1'. Those pesky Summer Students at MS eh? Kristen |
 |
|
|
|