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 |
|
hanglam
Starting Member
7 Posts |
Posted - 2005-11-15 : 18:49:20
|
| Hi,I have a table with the following columns:Table1:PersonID, [1], [2], [3],][4] , [5] and so on .The TABLE FIELD NAMES are actual numbers (not letters) representing the days of a month.I'mm writing a stored procedure to populate this table with UPDATE Statement (NOT INSERT statements as the PersonID is already in the table)is there any way for me to access the column as a array ?For example:UPDATE Table1 Set column[4] = 'hello' where PersonID = 1I tried this:declare @index varchar(2)set @index = '3' (column with the name '3')UPDATE Table1 Set @index = 'hello' where PersonID = 1but it doesn't work.Thanks,Hang |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2005-11-15 : 19:31:49
|
| Have you thought about redesigning your table? You can do this with dynamic SQL; however, the design is questionable. It might be better to have a column indicating what day of the month it is. Have you explored dynamic SQL at all?MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
|
|
|
|
|