I have a table for example with fields(a:int,b:int,c:int,d:int)
I am writing a store procedure. This store procedure will give a string(‘a’ or ‘b’ or ‘c’ or ‘d’) and should give back sum on that column.
I am using SQL server 2005.
I have a table for example with fields(a:int,b:int,c:int,d:int) I am writing a store procedure.
Share
Try to redesign your database so that you’re not trying to implement the same operations against multiple columns. Just because SQL tables resemble a spreadsheet, that doesn’t mean you should treat it as such.
It sounds like you may have some form of attribute splitting going on – where you have multiple columns representing the same “type” of data, when you should have multiple rows, and an additional column to distinguish these values (e.g. rather than having twelve columns to represent “values” from each month of the year, you should have two columns, storing month and “value”).