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 |
|
besadmin
Posting Yak Master
116 Posts |
Posted - 2011-05-09 : 11:54:02
|
| Hey Friends!I am trying to make a stored proc that will insert into about 15 different tables. So Is there a way to pass in all those values in each mode or something, rather than having to declare like 100 parameters for each??Like this kind of...IF @Mode = Table1 insert into table 1 var 1, var 2values var 1, var 2ELSE IF @Mode = Table2 insert into table 2 var 1, var 2values var 1, var 2So, how should i split those up? make a different SP for each table? using a mode somehow? or must i declare @@ variables at the top? which seems crazy becuase each insert will only have about 5-10 columns, but that would require like 100 variables to be declared at the top??Any help is greatly appreciated as always freinds!!Thanks so much in advance!! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2011-05-09 : 13:28:34
|
| Sniped - but I'll proceed anyway :)Good practice is to have an SP for each target table with well typed parameters. You definitely don't want to have a single master sp that performs all your database interaction. It becomes unruly, hard to read, and hard to maintain, execution plans will often be wrong, etc...Be One with the OptimizerTG |
 |
|
|
besadmin
Posting Yak Master
116 Posts |
Posted - 2011-05-10 : 12:05:52
|
| Yes, I guess using the mode is better for different procs and 1 table or query.I will use the separate sp's.Thanks a ton for you quick responses guys!Always appreciated so much!Thanks again! |
 |
|
|
|
|
|
|
|