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 |
|
Progress2007
Starting Member
17 Posts |
Posted - 2009-03-12 : 03:33:10
|
| HelloMy table sturcture is like thisclient Column1 Column2 Column3 Column 4 TotalA 10 20 30 40 100 B 20 40 50 60 170---------------------------------------------------------------- 30 60 80 100 170I want to do this by Stored procudureone more thing the columns are dynamic.Now how can i perform this query |
|
|
asgast
Posting Yak Master
149 Posts |
Posted - 2009-03-12 : 04:14:02
|
| if your columns are dynamic, the simplest solution is to use dynamic sql, pass the columns you want to sum as a parameter for the SP. Then use it to make a string and execute it. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-03-12 : 05:06:26
|
quote: Originally posted by Progress2007 HelloMy table sturcture is like thisclient Column1 Column2 Column3 Column 4 TotalA 10 20 30 40 100 B 20 40 50 60 170---------------------------------------------------------------- 30 60 80 100 170I want to do this by Stored procudureone more thing the columns are dynamic.Now how can i perform this query
Where do you want to show data?MadhivananFailing to plan is Planning to fail |
 |
|
|
Progress2007
Starting Member
17 Posts |
Posted - 2009-03-12 : 05:22:16
|
| just i want that i coluld able to create a SP with a SQL queryand the result of this Query should bound to a datagrid |
 |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2009-03-12 : 06:56:41
|
| is this u wantselect Column1, Column2, Column3, Column4 from URTABLENAME COMPUTE SUM( Column1),SUM(Column2),SUM(Column3),SUM(Column4) |
 |
|
|
|
|
|