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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 select all from table

Author  Topic 

debradeng
Starting Member

46 Posts

Posted - 2006-10-21 : 01:27:54
I am creating SPs by usging some given queries.Most of them is to select all records from a certain table.I am thinking to use table name as parameter to create one SP for all those queris instead of one SP for each query.I know how to create such a SP,but I am not sure if it is a good idea.In the "SELECT " statement,listing all columns rather than using "*" may imply something?

Does anybody have any suggestion?

Thank you!

LoztInSpace
Aged Yak Warrior

940 Posts

Posted - 2006-10-21 : 02:02:15
I would not do this. One SP per table is best - you can dynamically chose which proc to call in the front end if you stick to a naming convention.
I know it seems a lot of unnecessary work but I guarantee your requirement will eventually change and your data model will have to mature to match. In the first instance, if it's really as simple as you say why not write a code generator to get you started.
Go to Top of Page

debradeng
Starting Member

46 Posts

Posted - 2006-10-21 : 03:46:39
Thank your for your advice,LoztInSpace.I really appreciate that!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-21 : 06:05:12
If you want to pass table name as parameter, you need to use dynamic sql, which in this case no need

Read this fully

http://www.sommarskog.se/dynamic_sql.html


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -