How to write store procedure

Posted by Gow.net under Sql Server on 12/17/2011 | Points: 10 | Views : 1068 | Status : [Member] | Replies : 3
Hi,

i need single stored Procedure using two insertion table, I want to know how to use multiple insertion queries in a single stored procedure. I am using Sql server 2005 as my back end. In my application form, i have put one control drop down list. When i clicked on the list, it will popup some names eg Sony,dell etc. So if i clicking one name means its information has to be stored into individual table named Sony, Dell so on. Kindly i request you to give me procedure to make it possible. It will be very thanks to you.

gowthaman8870226416


Responses

Posted by: Sksamantaray on: 12/17/2011 [Member] Silver | Points: 25

Up
0
Down

Your dropdown decides the target table to which data will be inserted.If so then in your procedure first you need to check the tables's existence first,
If table exists then build up your query using table name parameter(dropdown) value and other values required for that table.
Keep everything in a string variable, then use Exec (@Variable)

Thanks,
Sanjay

Gow.net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sriramnandha on: 6/22/2012 [Member] Starter | Points: 25

Up
0
Down
First Check Table exists or Not use case Statements in Stored procedure and use Table name parameter in DropDown values.


Regards

sriram.r

sriram

Gow.net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: CGN007 on: 6/23/2012 [Member] Silver | Points: 25

Up
0
Down
http://www.codeproject.com/Articles/38682/Overview-of-SQL-Server-Stored-Procedure

Gow.net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response