Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

One Stored Procedure

One Stored Procedure

One Stored Procedure

what about create one stored procedure handle all select and insert and delete in my database table and take the name of the table and the id of the process that i want to do it (insert - update - delete ) and this stored procedure detect the fields of the table and the primary key .

instead of creating stored procedures to insert , update and delete to every table  


if i make this stored procdure it will affect on performance or not ????

incase of i want to deal with any table i will ask him about fields ,primary key ,foreign key and so on

after that i will make my process of (update-select - delete)

RE: One Stored Procedure

You don't really want one stored procedure to do everything.  It will make your life a living hell when it's time to make a change.

Also, it sounds like you're using SQL Server so maybe you want this forum?  forum183: Microsoft SQL Server: Programming

Good Luck,


----signature below----
According to recent reports, the US Missile Defense System is actually just Cole Hamels on Speed Dial.

Ignorance of certain subjects is a great part of wisdom

RE: One Stored Procedure

Can a stored procedure detect fields in a table? yes. This is SQL server but others will be similar.


SELECT column_name, data_type, is_nullable, column_default
FROM information_schema.columns
WHERE table_name = 'Region' --Put your table name here
ORDER BY ordinal_position


RE: One Stored Procedure

One stored proc to do all this is an extremelly poor idea. It might take less time to create, but it will cause problems in maintaining and it will be most inefficient in running. It will also be a security hazard (read about SQL Injection attacks to see why dynamic SQL is a Bad bad idea). Oh yes testing it will be a bad thing as well.

If you do this, I hope you have audit tables so that you can recover from the data integrity problems you will create.

"NOTHING is more important in a database than integrity." ESquared

RE: One Stored Procedure

... even better.. you could just have 1 table - with thingname, thingvalue, relatedthing and relationtype columns - wouldn't that make things much easier on the table design, eh ?

you could also have a generic screen which had 1 column of things and the second column of thing values - then have an action button at the end that simply said 'do it'.  

Actually, no, I've a better idea - why not have 1 column, and 1 row called 'data', then you could simply have 1 screen with one field and one button.. !!!!!!111!!!11!!1!1!1!!  cool....  oh, wait... isn't that notepad ?

 winky smile


A smile is worth a thousand kind words. So smile, it's easy! smile

RE: One Stored Procedure


No, no...

One ring to rule them all...

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close