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
 SQL Server Development (2000)
 Conversion Problem

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 datatype
as a1, a2, a3, a4, a5, a6 and goes on until a16
Now, I wanna use loop and update the above table
for each field by executing one more proc which gets me the data which would be corresponding to each of (a) with a number each time

I 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 Luck

Brett

8-)

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 Float

Select @intCounter = 1

Select @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
END
Exec(@strCMD)

Go to Top of Page
   

- Advertisement -