General information
Forum:
Microsoft SQL Server
Environment versions
SQL Server:
SQL Server 2005
Hi,
I am trying to move a verable to the sp_executesql but i have an error:-
SELECT @position = LEN(@inputNumber) - 2
set @x=1
WHILE @x<=3
begin
set @esql =N'set @xnum'+ convert(varchar(10),@x)+' = RIGHT(''000'' + SUBSTRING('+@inputNumber+','+convert(varchar(10),@position)+', 3), 3)'
exec sp_executesql @esql, N'''@xnum'+convert(varchar(10),@x)+' char(3) INT output''','@xnum'+convert(varchar(10),@x) output
set @x=@x+1
SELECT @counter = @counter + 1
, @position = @position - 3
END
end
the error message:
Msg 102, Level 15, State 1, Procedure Currencyjbm, Line 153
Incorrect syntax near '+'.
the dynmic @esql ..
set @xnum1 = RIGHT('000' + SUBSTRING(3211110,5, 3), 3)
set @xnum2 = RIGHT('000' + SUBSTRING(3211110,2, 3), 3)
set @xnum3 = RIGHT('000' + SUBSTRING(3211110,-1, 3), 3)
please any help.
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only