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 |
doubleotwo
Yak Posting Veteran
69 Posts |
Posted - 2010-08-19 : 04:42:18
|
is it possible to call a sp with something like @1 = 'foo' ? insteadof the full name of that param ? |
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-08-19 : 04:51:33
|
As far as i know, you cannot call the parameter by the number. You either need to use the parameter name or pass in the same order (without specifying the name).I am here to learn from Masters and help new bees in learning. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-08-19 : 05:01:58
|
quote: Originally posted by doubleotwo is it possible to call a sp with something like @1 = 'foo' ? insteadof the full name of that param ?
Why do you want to do this?MadhivananFailing to plan is Planning to fail |
|
|
Kristen
Test
22859 Posts |
Posted - 2010-08-19 : 05:21:00
|
You can call a Stored Procedure withoyut ANY parameter names, BUT the parameters MUST be in the right order (and the problem is that that order may change in the future - e.g. if a developer "adds one" or similar). There are also some issues about parameters which are defined with default values - I'm a bit hazzy on that, but it may mean you get a run time error, retrospectively for code that used to work, if you add a Default value to a parameter's definition (i.e. one that used not to have a default)So, instead of your proposed EXEC MySproc @1 = 'foo'you can haveEXEC MySproc @Param1Name = 'foo'or justEXEC MySproc 'foo' |
|
|
doubleotwo
Yak Posting Veteran
69 Posts |
Posted - 2010-08-19 : 05:47:53
|
ow. .. i really tought this was possible..i want to add my parameters with a .NET programi got a datatable and want to do some checks on each rowand insert/update according to the check...but instead of programming each par , i wanted to just create a loop...now i can rename all the pars of the sp with something like par1 par2 ...this should fix it :)thx anyways ! |
|
|
|
|
|