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.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Create Calulations using field name in stored proc.

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2007-01-29 : 10:17:48
Lea writes "Hello, I have a table that looks like this. It has 18 columns of sales data.

fields:
fldProduct,fldOffset,[1],[2],[3],[4],[5],[6],[7],......[18]
data:
ProductA,-3,100,140,150,175,180,125,300,.......200

The fldOffset contains a number like +2 or -3.

I was previously doing this in a vb function using an array, but now I need to move it to a stored procedure for processing on the server.

I need to take the data in column(x) and offset it by fldOffset and put it back in column (x + fldoffset).

Using the data above, the offset is -3, I would take the data in column [4] (175) and move it to column [1], column [5] to [2], [6] to [3] and so on. Everything in this record would move back 3 columns. The next record may have a different offset say +2, and I would move everything forward or to the right 2 columns.

Any assistance would be greatly appreciated."

Srinika
Master Smack Fu Yak Hacker

1378 Posts

Posted - 2007-01-29 : 12:05:40
In ur eg. with offset -3 what will happen to the last 3 records that already exists
and eg. with offset +2 what will happen to the first 2 records that already exists

Is this kind of homework ?
How many records r there in the table ?

Srinika
Go to Top of Page
   

- Advertisement -