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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-01-30 : 08:18:48
|
| Sandy writes "Hi,I can explain my Q with an example.I have a table with fields of float datatypeas a1, a2, a3, a4, a5, a6 and goes on until a16Now, I wanna use loop and update the above tablefor each field by executing one more proc which gets me the data which would be corresponding to each of (a) with a number each timeI cannot concatenate in a proc with a + 'number'and say update a+'number' = result of a proc.it says conversion problem.I hope u got my question...Please do the needful..thanks in advance" |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-01-30 : 11:05:56
|
| Maybe something like this?Good LuckBrett8-)ps for some reason the plus(+) signa for concatenation don't show up in the preview...just make sure you add them if the post doesn't add them.Declare @strCMD varchar(4000), @intCounter int, @floatVar FloatSelect @intCounter = 1Select @strCMD = 'UPDATE Tablename Set 'While @intCounter < 16 BEGIN If @intCounter = 1 Then @STRcmd = ' A' + Convert(varchar(2),@intCounter) + ' = ' ELSE @STRcmd = ', A' + Convert(varchar(2),@intCounter) + ' = ' @floatVar = Exec usp_????? -- Assuming the value is passed out this way @strCMD = '''' + @floatVar + '''' @intCounter = intCounter + 1 ENDExec(@strCMD) |
 |
|
|
|
|
|