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 |
suriyarupa
Starting Member
19 Posts |
Posted - 2013-03-22 : 02:34:28
|
I have a table Region. It contains 6 columns as CutomerName, Northregion, southregion, Westregion, eastregion and northeastregion. Now i want to insert values to Region table. From one SP i aam calculating Volumes for each regions. EG. Exec SP_Getvolume 'Input'.Input for SP is brand name. For each brand, and for each region it will return the volumes of each customers. Result of SP will be like this.CustomerName NorthRegion SouthRegion EastregionC1 234.56 789.45 980.8C2 43.7 578.98 3243.90Now i want to insert this output to my Region table. Here for each brands no. of columns will be changing. So dynamically i want to insert all columns whatever SP is returning. Please help me. |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-03-22 : 05:34:57
|
this is not a good way to design the system. If purpose of procedure is only to return columns for saving it in your Region table I would suggest making it table valued UDF and then always return all the regions. In case of no values for one put a place holder (NULL or 0 based on your system rule). then you can write a simple static UPDATE to join your table to UDF and update values of columns after checking if value is available.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|