Click here to Skip to main content
15,891,845 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,
I want to pass columns and values dynamically in the SQL Insert Statement.Means the columns and values will varies based on some condition.

Note: I want to use only one SQL Insert Statement.


I want to pass Array as Parameter in StoredProcedur.
Example:
INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...)

I want to pass columns and values as array in StoredProcedure.
Posted
Updated 22-Jun-15 0:42am
v2
Comments
Mathew Soji 22-Jun-15 4:57am    
Have you tried on some code ? If not please refer below one for sample implementation .

http://www.codeproject.com/Articles/14528/Generate-SQL-INSERT-commands-programmatically
OriginalGriff 22-Jun-15 5:02am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Perhaps an example would help us to understand?
Use the "Improve question" widget to edit your question and provide better information.
Thanks7872 22-Jun-15 5:59am    
And what is your question?
Merajuddin Ansari 22-Jun-15 6:41am    
I want to pass Array as Parameter in StoredProcedur.
Example:
INSERT INTO table_name (column1,column2,column3,...) VALUES (value1,value2,value3,...)

I want to pass columns and values as array in StoredProcedure.

1 solution

It is easy, you have to create temporary tables and send them into you stored procedure.

Try to read this:
http://aspalliance.com/1891_Pass_Tables_to_Stored_Procedure__Table_Valued_Parameter.2[^]

It is a good example ;)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900